noBaseBuilding::noBaseBuilding(SerializedGameData * sgd, const unsigned obj_id) : noRoadNode(sgd,obj_id), type(BuildingType(sgd->PopUnsignedChar())), nation(Nation(sgd->PopUnsignedChar())), door_point_x(sgd->PopSignedInt()), door_point_y(sgd->PopSignedInt()) { }
void SavedFile::ReadPlayerData(BinaryFile& file) { for(std::vector<Player>::iterator it = players.begin(); it != players.end(); ++it) { it->ps = file.ReadUnsignedInt(); if(it->ps != PS_LOCKED) { it->name = file.ReadShortString(); it->nation = Nation(file.ReadUnsignedChar()); it->color = file.ReadUnsignedInt(); it->team = file.ReadUnsignedChar(); } } }
/// Deserialisierungskonstruktor GamePlayerInfo::GamePlayerInfo(const unsigned playerid, Serializer* ser) : playerid(playerid), ps(PlayerState(ser->PopUnsignedChar())), aiInfo(), name(ser->PopString()), origin_name(ser->PopString()), is_host(ser->PopBool()), nation(Nation(ser->PopUnsignedChar())), team(Team(ser->PopUnsignedChar())), color(ser->PopUnsignedChar()), ping(ser->PopUnsignedInt()), rating(ser->PopUnsignedInt()), obj_cnt(0), obj_id_cnt(0), ready(ser->PopBool()) { }
/** * * @author OLiver */ void SavedFile::ReadPlayerData(BinaryFile& file) { // ggf. wieder löschen delete[] players; players = new SavedFile::Player[player_count]; for(unsigned char i = 0; i < player_count; ++i) { players[i].ps = file.ReadUnsignedInt(); if(players[i].ps != PS_LOCKED) { file.ReadShortString(players[i].name); players[i].nation = Nation(file.ReadUnsignedChar()); players[i].color = file.ReadUnsignedChar(); players[i].team = file.ReadUnsignedChar(); } } }
/** * * * @author FloSoft */ void GameClient::Command_ToggleNation() { send_queue.push(new GameMessage_Player_Toggle_Nation (0xff, Nation((this->GetLocalPlayer()->nation + 1) % NAT_COUNT))); }
fowBuildingSite::fowBuildingSite(SerializedGameData& sgd) : planing(sgd.PopBool()), type(BuildingType(sgd.PopUnsignedChar())), nation(Nation(sgd.PopUnsignedChar())), build_progress(sgd.PopUnsignedChar()) {}
fowBuilding::fowBuilding(SerializedGameData& sgd) : type(BuildingType(sgd.PopUnsignedChar())), nation(Nation(sgd.PopUnsignedChar())) {}
ImagePostMsgWithLocation::ImagePostMsgWithLocation(SerializedGameData* sgd) : PostMsgWithLocation(sgd), senderBuilding(BuildingType(sgd->PopUnsignedInt())), senderNation(Nation(sgd->PopUnsignedInt())) { }
fowFlag::fowFlag(SerializedGameData& sgd) : color(sgd.PopUnsignedInt()), nation(Nation(sgd.PopUnsignedChar())), flag_type(FlagType(sgd.PopUnsignedChar())) {}
void dskHostGame::Msg_Group_ButtonClick(const unsigned int group_id, const unsigned int ctrl_id) { unsigned player_id = 8 - (group_id - 50); switch(ctrl_id) { // Klick auf Spielername case 1: { if(GAMECLIENT.IsHost()) GAMESERVER.TogglePlayerState(player_id); } break; // Volk case 3: { TogglePlayerReady(player_id, false); if(GAMECLIENT.IsHost()) GAMESERVER.TogglePlayerNation(player_id); if(player_id == GAMECLIENT.GetPlayerID()) { GAMECLIENT.Command_ToggleNation(); GameClientPlayer& localPlayer = GAMECLIENT.GetLocalPlayer(); localPlayer.nation = Nation((unsigned(localPlayer.nation) + 1) % NAT_COUNT); ChangeNation(GAMECLIENT.GetPlayerID(), localPlayer.nation); } } break; // Farbe case 4: { TogglePlayerReady(player_id, false); if(player_id == GAMECLIENT.GetPlayerID()) { // Get colors used by other players std::set<unsigned> takenColors; for(unsigned p = 0; p < GAMECLIENT.GetPlayerCount(); ++p) { // Skip self if(p == GAMECLIENT.GetPlayerID()) continue; GameClientPlayer& otherPlayer = GAMECLIENT.GetPlayer(p); if(otherPlayer.isUsed()) takenColors.insert(otherPlayer.color); } // Look for a unique color GameClientPlayer& player = GAMECLIENT.GetLocalPlayer(); int newColorIdx = player.GetColorIdx(player.color); do{ player.color = PLAYER_COLORS[(++newColorIdx) % PLAYER_COLORS.size()]; } while(helpers::contains(takenColors, player.color)); GAMECLIENT.Command_SetColor(); ChangeColor(GAMECLIENT.GetPlayerID(), player.color); } else if(GAMECLIENT.IsHost()) GAMESERVER.TogglePlayerColor(player_id); // Start-Farbe der Minimap ändern } break; // Team case 5: { TogglePlayerReady(player_id, false); if(GAMECLIENT.IsHost()) GAMESERVER.TogglePlayerTeam(player_id); if(player_id == GAMECLIENT.GetPlayerID()) { if(GAMECLIENT.GetLocalPlayer().team > TM_RANDOMTEAM && GAMECLIENT.GetLocalPlayer().team < Team(TEAM_COUNT)) // team: 1->2->3->4->0 //-V807 { GAMECLIENT.GetLocalPlayer().team = Team((GAMECLIENT.GetLocalPlayer().team + 1) % TEAM_COUNT); } else { if(GAMECLIENT.GetLocalPlayer().team == TM_NOTEAM) // 0(noteam)->randomteam(1-4) { int rnd = RANDOM.Rand(__FILE__, __LINE__, 0, 4); if(!rnd) GAMECLIENT.GetLocalPlayer().team = TM_RANDOMTEAM; else GAMECLIENT.GetLocalPlayer().team = Team(rnd + 5); } else //any randomteam -> team 1 { GAMECLIENT.GetLocalPlayer().team = TM_TEAM1; } } GAMECLIENT.Command_ToggleTeam(GAMECLIENT.GetLocalPlayer().team); ChangeTeam(GAMECLIENT.GetPlayerID(), GAMECLIENT.GetLocalPlayer().team); } } break; } }