Main.SideBar (edit) |
Main /
PlayerIdsThis site describes the idea of changing the current scheme of PlayerIds in Boson. UPDATE: This site still described the old situation. The "current situation" described below is the way it worked before. We now use the PlayerId Scheme Proposal that is presented below. The current situationRight now we use the ID of KPlayer::id() as Boson PlayerIds. These IDs are also used by KGame internally which means that the client ID is encoded in the player ID: if you have two players on client A, they'll probably have IDs 1025 and 1026, but if these players are on clients A and B, then they'll probably have IDs 1025 and 2049. Therefore the fileformats (.bpf/.bsg files) cannot store the actual game ID: when starting a game, the IDs might have changed compared to when they were saved. This is why we use the "index" of the player in the playerlist as a PlayerId in the file formats. On startup this "dummy" ID is replaced by the real PlayerId (by BosonStarting::fixPlayerIds()). Why change anything?The current PlayerId scheme is flawed. It has caused a lot of trouble in the past - these issues have been fixed meanwhile, but I can already foresee future problems:
All of these are "fixable", but require additional code and some work. None of these is an issue right now: none of our current features depends on these. But all of them will turn out to be an issue later. These are the main issues of the current scheme (IIRC), though I have already noticed a few other issues that will cause us headache one day. By fixing the problems described above, we would merely be fixing the symptoms. We really should go for fixing the problem and we should go for it now. PlayerId? Scheme ProposalInstead of using KPlayer::id(), we should use KPlayer::userId(). userId() is not touched by KGame, so we can use free IDs in the way we want to. Some properties:
ID assignment:
see below on what "invalid" IDs can be used for (the "invalid" refers to "invalid for game players" only)
Players with these IDs are never relevant for winning conditions, that is they cannot win or lose. Note however,that the state of such a player can be relevant to winning conditions of a different player (such as "protect civilians").
Additional notes:
|