bool displayGameOver(bool bDidit) { if (bDidit) { setPlayerHasWon(true); multiplayerWinSequence(true); if (bMultiPlayer) { updateMultiStatsWins(); } } else { setPlayerHasLost(true); if (bMultiPlayer) { updateMultiStatsLoses(); } } if (bMultiPlayer) { PLAYERSTATS st = getMultiStats(selectedPlayer); saveMultiStats(getPlayerName(selectedPlayer), getPlayerName(selectedPlayer), &st); } //clear out any mission widgets - timers etc that may be on the screen clearMissionWidgets(); intAddMissionResult(bDidit, true); return true; }
void formAlliance(uint8_t p1, uint8_t p2, bool prop, bool allowAudio, bool allowNotification) { DROID *psDroid; char tm1[128]; if (bMultiMessages && prop) { sendAlliance(p1, p2, ALLIANCE_FORMED, false); return; // Wait for our message. } // Don't add message if already allied if (bMultiPlayer && alliances[p1][p2] != ALLIANCE_FORMED && allowNotification) { sstrcpy(tm1, getPlayerName(p1)); CONPRINTF(ConsoleString, (ConsoleString, _("%s Forms An Alliance With %s"), tm1, getPlayerName(p2))); } syncDebug("Form alliance %d %d", p1, p2); triggerEventAllianceAccepted(p1, p2); alliances[p1][p2] = ALLIANCE_FORMED; alliances[p2][p1] = ALLIANCE_FORMED; if (bMultiPlayer && alliancesSharedVision(game.alliance)) // this is for shared vision only { alliancebits[p1] |= 1 << p2; alliancebits[p2] |= 1 << p1; } if (allowAudio && (p1 == selectedPlayer || p2 == selectedPlayer)) { audio_QueueTrack(ID_ALLIANCE_ACC); } // Not campaign and alliances are transitive if (bMultiPlayer && alliancesSharedVision(game.alliance)) { giftRadar(p1, p2, false); giftRadar(p2, p1, false); } // Clear out any attacking orders for (psDroid = apsDroidLists[p1]; psDroid; psDroid = psDroid->psNext) // from -> to { if (psDroid->order.type == DORDER_ATTACK && psDroid->order.psObj && psDroid->order.psObj->player == p2) { orderDroid(psDroid, DORDER_STOP, ModeImmediate); } } for (psDroid = apsDroidLists[p2]; psDroid; psDroid = psDroid->psNext) // to -> from { if (psDroid->order.type == DORDER_ATTACK && psDroid->order.psObj && psDroid->order.psObj->player == p1) { orderDroid(psDroid, DORDER_STOP, ModeImmediate); } } }
void breakAlliance(uint8_t p1, uint8_t p2, BOOL prop, BOOL allowAudio) { char tm1[128]; if (alliances[p1][p2] == ALLIANCE_FORMED) { sstrcpy(tm1, getPlayerName(p1)); CONPRINTF(ConsoleString,(ConsoleString,_("%s Breaks The Alliance With %s"),tm1,getPlayerName(p2) )); if (allowAudio && (p1 == selectedPlayer || p2 == selectedPlayer)) { audio_QueueTrack(ID_ALLIANCE_BRO); } } alliances[p1][p2] = ALLIANCE_BROKEN; alliances[p2][p1] = ALLIANCE_BROKEN; alliancebits[p1] &= ~(1 << p2); alliancebits[p2] &= ~(1 << p1); if (prop) { sendAlliance(p1, p2, ALLIANCE_BROKEN, false); } }
void requestAlliance(uint8_t from, uint8_t to, BOOL prop, BOOL allowAudio) { alliances[from][to] = ALLIANCE_REQUESTED; // We've asked alliances[to][from] = ALLIANCE_INVITATION; // They've been invited CBallFrom = from; CBallTo = to; eventFireCallbackTrigger((TRIGGER_TYPE) CALL_ALLIANCEOFFER); if (to == selectedPlayer) { CONPRINTF(ConsoleString,(ConsoleString,_("%s Requests An Alliance With You"),getPlayerName(from))); if (allowAudio) { audio_QueueTrack(ID_ALLIANCE_OFF); } } else if (from == selectedPlayer) { CONPRINTF(ConsoleString,(ConsoleString,_("You Invite %s To Form An Alliance"),getPlayerName(to))); if (allowAudio) { audio_QueueTrack(ID_ALLIANCE_OFF); } } if (prop) { sendAlliance(from, to, ALLIANCE_REQUESTED, false); } }
void requestAlliance(uint8_t from, uint8_t to, bool prop, bool allowAudio) { if (prop && bMultiMessages) { sendAlliance(from, to, ALLIANCE_REQUESTED, false); return; // Wait for our message. } syncDebug("Request alliance %d %d", from, to); alliances[from][to] = ALLIANCE_REQUESTED; // We've asked alliances[to][from] = ALLIANCE_INVITATION; // They've been invited CBallFrom = from; CBallTo = to; eventFireCallbackTrigger((TRIGGER_TYPE) CALL_ALLIANCEOFFER); if (to == selectedPlayer) { CONPRINTF(ConsoleString, (ConsoleString, _("%s Requests An Alliance With You"), getPlayerName(from))); if (allowAudio) { audio_QueueTrack(ID_ALLIANCE_OFF); } } else if (from == selectedPlayer) { CONPRINTF(ConsoleString, (ConsoleString, _("You Invite %s To Form An Alliance"), getPlayerName(to))); if (allowAudio) { audio_QueueTrack(ID_ALLIANCE_OFF); } } }
void breakAlliance(uint8_t p1, uint8_t p2, bool prop, bool allowAudio) { char tm1[128]; if (prop && bMultiMessages) { sendAlliance(p1, p2, ALLIANCE_BROKEN, false); return; // Wait for our message. } if (alliances[p1][p2] == ALLIANCE_FORMED) { sstrcpy(tm1, getPlayerName(p1)); CONPRINTF(ConsoleString, (ConsoleString, _("%s Breaks The Alliance With %s"), tm1, getPlayerName(p2))); if (allowAudio && (p1 == selectedPlayer || p2 == selectedPlayer)) { audio_QueueTrack(ID_ALLIANCE_BRO); } } syncDebug("Break alliance %d %d", p1, p2); alliances[p1][p2] = ALLIANCE_BROKEN; alliances[p2][p1] = ALLIANCE_BROKEN; alliancebits[p1] &= ~(1 << p2); alliancebits[p2] &= ~(1 << p1); }
void Client::startAuth(AuthMechanism chosen_auth_mechanism) { m_chosen_auth_mech = chosen_auth_mechanism; switch (chosen_auth_mechanism) { case AUTH_MECHANISM_FIRST_SRP: { // send srp verifier to server NetworkPacket resp_pkt(TOSERVER_FIRST_SRP, 0); char *salt, *bytes_v; std::size_t len_salt, len_v; salt = NULL; getSRPVerifier(getPlayerName(), m_password, &salt, &len_salt, &bytes_v, &len_v); resp_pkt << std::string((char*)salt, len_salt) << std::string((char*)bytes_v, len_v) << (u8)((m_password == "") ? 1 : 0); free(salt); free(bytes_v); Send(&resp_pkt); break; } case AUTH_MECHANISM_SRP: case AUTH_MECHANISM_LEGACY_PASSWORD: { u8 based_on = 1; if (chosen_auth_mechanism == AUTH_MECHANISM_LEGACY_PASSWORD) { m_password = translatePassword(getPlayerName(), m_password); based_on = 0; } std::string playername_u = lowercase(getPlayerName()); m_auth_data = srp_user_new(SRP_SHA256, SRP_NG_2048, getPlayerName().c_str(), playername_u.c_str(), (const unsigned char *) m_password.c_str(), m_password.length(), NULL, NULL); char *bytes_A = 0; size_t len_A = 0; SRP_Result res = srp_user_start_authentication( (struct SRPUser *) m_auth_data, NULL, NULL, 0, (unsigned char **) &bytes_A, &len_A); FATAL_ERROR_IF(res != SRP_OK, "Creating local SRP user failed."); NetworkPacket resp_pkt(TOSERVER_SRP_BYTES_A, 0); resp_pkt << std::string(bytes_A, len_A) << based_on; Send(&resp_pkt); break; } case AUTH_MECHANISM_NONE: break; // not handled in this method } }
// //////////////////////////////////////////////////////////////////////////// // A remote player has left the game bool MultiPlayerLeave(UDWORD playerIndex) { char buf[255]; if (playerIndex >= MAX_PLAYERS) { ASSERT(false, "Bad player number"); return false; } NETlogEntry("Player leaving game", SYNC_FLAG, playerIndex); debug(LOG_NET,"** Player %u [%s], has left the game at game time %u.", playerIndex, getPlayerName(playerIndex), gameTime); ssprintf(buf, _("%s has Left the Game"), getPlayerName(playerIndex)); if (ingame.localJoiningInProgress) { clearPlayer(playerIndex, false); } else if (NetPlay.isHost) // If hosting, and game has started (not in pre-game lobby screen, that is). { sendPlayerLeft(playerIndex); } game.skDiff[playerIndex] = 0; addConsoleMessage(buf, DEFAULT_JUSTIFY, SYSTEM_MESSAGE); if (NetPlay.players[playerIndex].wzFile.isSending) { char buf[256]; ssprintf(buf, _("File transfer has been aborted for %d.") , playerIndex); addConsoleMessage(buf, DEFAULT_JUSTIFY, SYSTEM_MESSAGE); debug(LOG_INFO, "=== File has been aborted for %d ===", playerIndex); NetPlay.players[playerIndex].wzFile.isSending = false; NetPlay.players[playerIndex].needFile = false; } NetPlay.players[playerIndex].kick = true; // Don't wait for GAME_GAME_TIME messages from them. if (widgGetFromID(psWScreen, IDRET_FORM)) { audio_QueueTrack(ID_CLAN_EXIT); } // fire script callback to reassign skirmish players. CBPlayerLeft = playerIndex; eventFireCallbackTrigger((TRIGGER_TYPE)CALL_PLAYERLEFT); netPlayersUpdated = true; return true; }
bool recvDataCheck(NETQUEUE queue) { int i = 0; uint32_t player = queue.index; uint32_t tempBuffer[DATA_MAXDATA] = {0}; NETbeginDecode(queue, NET_DATA_CHECK); for(i = 0; i < DATA_MAXDATA; i++) { NETuint32_t(&tempBuffer[i]); } NETend(); if (player >= MAX_PLAYERS) // invalid player number. { debug(LOG_ERROR, "invalid player number (%u) detected.", player); return false; } debug(LOG_NET, "** Received NET_DATA_CHECK from player %u", player); if (NetPlay.isHost) { if (memcmp(DataHash, tempBuffer, sizeof(DataHash))) { char msg[256] = {'\0'}; for (i=0; i<DATA_MAXDATA; i++) { if (DataHash[i] != tempBuffer[i]) break; } sprintf(msg, _("%s (%u) has an incompatible mod, and has been kicked."), getPlayerName(player), player); sendTextMessage(msg, true); addConsoleMessage(msg, LEFT_JUSTIFY, NOTIFY_MESSAGE); kickPlayer(player, "your data doesn't match the host's!", ERROR_WRONGDATA); debug(LOG_WARNING, "%s (%u) has an incompatible mod. ([%d] got %x, expected %x)", getPlayerName(player), player, i, tempBuffer[i], DataHash[i]); debug(LOG_POPUP, "%s (%u), has an incompatible mod. ([%d] got %x, expected %x)", getPlayerName(player), player, i, tempBuffer[i], DataHash[i]); return false; } else { debug(LOG_NET, "DataCheck message received and verified for player %s (slot=%u)", getPlayerName(player), player); ingame.DataIntegrity[player] = true; } } return true; }
void cheat_friends() { if (set.friendchecker) { if (!gta_menu_active() && g_Players && g_Players->pRemotePlayer) { int count = 0; for (int i = 0; i < SAMP_MAX_PLAYERS; i++) { if (g_Players->iIsListed[i] != 1) continue; if (g_Players->pRemotePlayer[i] == NULL) continue; for (int x = 0; x < 300; x++) { if (getPlayerName(i) == NULL || set.admin[x] == NULL) break; if (!strcmp(getPlayerName(i), set.frend[x])) { D3DCOLOR color; char text[64]; if (vect3_near_zero(g_stStreamedOutInfo.fPlayerPos[i]) && (g_Players->pRemotePlayer[i]->pPlayerData == NULL || g_Players->pRemotePlayer[i]->pPlayerData->pSAMP_Actor == NULL)) { color = D3DCOLOR_XRGB(255, 165, 0); sprintf(text, "[ID: %d][LVL: %d] %s", i, g_Players->pRemotePlayer[i]->iScore, getPlayerName(i)); } else { color = D3DCOLOR_XRGB(255, 0, 0); sprintf(text, "[ID: %d][LVL: %d] %s", i, g_Players->pRemotePlayer[i]->iScore, getPlayerName(i)); } pD3DFont->PrintShadow(pPresentParam.BackBufferWidth - pD3DFont->DrawLength("Друзья в сети:") - 3, pPresentParam.BackBufferHeight / 2 - 20, D3DCOLOR_XRGB(255, 165, 0), "Друзья в сети:"); pD3DFont->PrintShadow(pPresentParam.BackBufferWidth - pD3DFont->DrawLength(text) - 3, pPresentParam.BackBufferHeight / 2 + count * 20, color, text); count++; } } } if (count == 0) { pD3DFont->PrintShadow(pPresentParam.BackBufferWidth - pD3DFont->DrawLength("Друзья в сети:") - 3, pPresentParam.BackBufferHeight / 2 - 20, D3DCOLOR_ARGB(100, 255, 165, 0), "Друзья в сети:"); pD3DFont->PrintShadow(pPresentParam.BackBufferWidth - pD3DFont->DrawLength("Нет друзей в сети") - 3, pPresentParam.BackBufferHeight / 2, D3DCOLOR_ARGB(100, 255, 165, 0), "Нет друзей в сети"); } } } }
// //////////////////////////////////////////////////////////////////////////// // give Power void giftPower(uint8_t from, uint8_t to, BOOL send) { UDWORD gifval; uint32_t dummy = 0; if (from == ANYPLAYER) { gifval = OILDRUM_POWER; } else { // Give 1/3 of our power away gifval = getPower(from) / 3; usePower(from, gifval); } addPower(to, gifval); if (send) { uint8_t giftType = POWER_GIFT; NETbeginEncode(NET_GIFT, NET_ALL_PLAYERS); NETuint8_t(&giftType); NETuint8_t(&from); NETuint8_t(&to); NETuint32_t(&dummy); NETend(); } else if (to == selectedPlayer) { CONPRINTF(ConsoleString,(ConsoleString,_("%s Gives You %u Power"),getPlayerName(from),gifval)); } }
void CTicTacToe::setPlayerPlay(int pNumber) { this->playerPlay = pNumber; g_cp.mainInstance->ui->textEditLog->append(getPlayerName(pNumber) + " ist nun am Zug. Mit Symbol: " + getPlayerCheckBoxStateString(pNumber)); }
// //////////////////////////////////////////////////////////////////////////// // Setup Stuff for a new player. void setupNewPlayer(UDWORD player) { UDWORD i; ingame.PingTimes[player] = 0; // Reset ping time ingame.JoiningInProgress[player] = true; // Note that player is now joining ingame.DataIntegrity[player] = false; for (i = 0; i < MAX_PLAYERS; i++) // Set all alliances to broken { alliances[selectedPlayer][i] = ALLIANCE_BROKEN; alliances[i][selectedPlayer] = ALLIANCE_BROKEN; } resetMultiVisibility(player); // set visibility flags. setMultiStats(player, getMultiStats(player), true); // get the players score if (selectedPlayer != player) { char buf[255]; ssprintf(buf, _("%s is joining the game"), getPlayerName(player)); addConsoleMessage(buf, DEFAULT_JUSTIFY, SYSTEM_MESSAGE); } }
// //////////////////////////////////////////////////////////////////////////// // give technologies. static void giftResearch(uint8_t from, uint8_t to, bool send) { int i; uint32_t dummy = 0; if (send) { uint8_t giftType = RESEARCH_GIFT; NETbeginEncode(NETgameQueue(selectedPlayer), GAME_GIFT); NETuint8_t(&giftType); NETuint8_t(&from); NETuint8_t(&to); NETuint32_t(&dummy); NETend(); } else if (alliancesCanGiveResearchAndRadar(game.alliance)) { if (to == selectedPlayer) { CONPRINTF(ConsoleString, (ConsoleString, _("%s Gives You Technology Documents"), getPlayerName(from))); } // For each topic for (i = 0; i < asResearch.size(); i++) { // If they have it and we don't research it if (IsResearchCompleted(&asPlayerResList[from][i]) && !IsResearchCompleted(&asPlayerResList[to][i])) { MakeResearchCompleted(&asPlayerResList[to][i]); researchResult(i, to, false, NULL, true); } } } }
// //////////////////////////////////////////////////////////////////////////// // give radar information void giftRadar(uint8_t from, uint8_t to, bool send) { uint32_t dummy = 0; if (send) { uint8_t subType = RADAR_GIFT; NETbeginEncode(NETgameQueue(selectedPlayer), GAME_GIFT); NETuint8_t(&subType); NETuint8_t(&from); NETuint8_t(&to); NETuint32_t(&dummy); NETend(); } // If we are recieving the gift else { hqReward(from, to); if (to == selectedPlayer) { CONPRINTF(ConsoleString, (ConsoleString, _("%s Gives You A Visibility Report"), getPlayerName(from))); } } }
static void giftAutoGame(uint8_t from, uint8_t to, bool send) { uint32_t dummy = 0; if (send) { uint8_t subType = AUTOGAME_GIFT; NETbeginEncode(NETgameQueue(selectedPlayer), GAME_GIFT); NETuint8_t(&subType); NETuint8_t(&from); NETuint8_t(&to); NETuint32_t(&dummy); NETend(); debug(LOG_SYNC, "We (%d) are telling %d we want to enable/disable a autogame", from, to); } // If we are recieving the "gift" else { if (to == selectedPlayer) { NetPlay.players[from].autoGame = !NetPlay.players[from].autoGame ; CONPRINTF(ConsoleString, (ConsoleString, "%s has %s the autoGame command", getPlayerName(from), NetPlay.players[from].autoGame ? "Enabled" : "Disabled")); debug(LOG_SYNC, "We (%d) are being told that %d has %s autogame", selectedPlayer, from, NetPlay.players[from].autoGame ? "Enabled" : "Disabled"); } } }
bool intDisplayMultiJoiningStatus(UBYTE joinCount) { UDWORD x,y,w,h; char sTmp[6]; w = RET_FORMWIDTH; h = RET_FORMHEIGHT; x = RET_X; y = RET_Y; // cameraToHome(selectedPlayer); // home the camera to the player. RenderWindowFrame(FRAME_NORMAL, x, y ,w, h); // draw a wee blu box. // display how far done.. iV_SetFont(font_regular); iV_DrawText(_("Players Still Joining"), x+(w/2)-(iV_GetTextWidth(_("Players Still Joining"))/2), y+(h/2)-8 ); unsigned playerCount = 0; // Calculate what NetPlay.playercount should be, which is apparently only non-zero for the host. for (unsigned player = 0; player < game.maxPlayers; ++player) { if (isHumanPlayer(player)) { ++playerCount; } } if (!playerCount) { return true; } iV_SetFont(font_large); sprintf(sTmp, "%d%%", PERCENT(playerCount - joinCount, playerCount)); iV_DrawText(sTmp ,x + (w / 2) - 10, y + (h / 2) + 10); iV_SetFont(font_small); int yStep = iV_GetTextLineSize(); int yPos = RET_Y - yStep*game.maxPlayers; static const std::string statusStrings[3] = {"☐ ", "☑ ", "☒ "}; for (unsigned player = 0; player < game.maxPlayers; ++player) { int status = -1; if (isHumanPlayer(player)) { status = ingame.JoiningInProgress[player]? 0 : 1; // Human player, still joining or joined. } else if (NetPlay.players[player].ai >= 0) { status = 2; // AI player (automatically joined). } if (status >= 0) { iV_DrawText((statusStrings[status] + getPlayerName(player)).c_str(), x + 5, yPos + yStep*NetPlay.players[player].position); } } return true; }
void WowData::updateAvatarName() { getPlayerName(nameAvatar); if (!nameAvatar.empty()) { nameAvatarValid = true; } else { nameAvatarValid = false; } }
static void addConsolePlayerLeftMessage(unsigned playerIndex) { if (selectedPlayer != playerIndex) { char buf[256]; ssprintf(buf, _("%s has Left the Game"), getPlayerName(playerIndex)); addConsoleMessage(buf, DEFAULT_JUSTIFY, SYSTEM_MESSAGE); } }
//////////////////////////////// // at the end of every game. bool multiGameShutdown(void) { PLAYERSTATS st; uint32_t time; debug(LOG_NET, "%s is shutting down.", getPlayerName(selectedPlayer)); sendLeavingMsg(); // say goodbye updateMultiStatsGames(); // update games played. st = getMultiStats(selectedPlayer); // save stats saveMultiStats(getPlayerName(selectedPlayer), getPlayerName(selectedPlayer), &st); // if we terminate the socket too quickly, then, it is possible not to get the leave message time = wzGetTicks(); while (wzGetTicks() - time < 1000) { wzYieldCurrentThread(); // TODO Make a wzDelay() function? } // close game NETclose(); NETremRedirects(); if (ingame.numStructureLimits) { ingame.numStructureLimits = 0; free(ingame.pStructureLimits); ingame.pStructureLimits = NULL; } ingame.flags = 0; ingame.localJoiningInProgress = false; // Clean up ingame.localOptionsReceived = false; ingame.bHostSetup = false; // Dont attempt a host ingame.TimeEveryoneIsInGame = 0; ingame.startTime = 0; NetPlay.isHost = false; bMultiPlayer = false; // Back to single player mode bMultiMessages = false; selectedPlayer = 0; // Back to use player 0 (single player friendly) return true; }
void cmd_change_server_fav ( char *param ) { traceLastFunc( "cmd_change_server_fav()" ); if ( strlen(param) == 0 ) { addMessageToChatWindow( "/m0d_fav_server <server name/part of server name>" ); addMessageToChatWindow( "In order to see the favorite server list type: /m0d_fav_server list" ); return; } if ( strncmp(param, "list", 4) == 0 ) { int count = 0; for ( int i = 0; i < INI_SERVERS_MAX; i++ ) { if ( set.server[i].server_name == NULL ) continue; count++; addMessageToChatWindow( "%s", set.server[i].server_name ); } if ( count == 0 ) addMessageToChatWindow( "No servers in favorite server list. Edit the ini file to add some." ); return; } char IP[257], LocalName[29]; int Port; strcpy( IP, g_SAMP->szIP ); Port = g_SAMP->ulPort; strcpy( LocalName, getPlayerName(g_Players->sLocalPlayerID) ); for ( int i = 0; i < INI_SERVERS_MAX; i++ ) { if ( set.server[i].server_name == NULL || set.server[i].ip == NULL || strlen(set.server[i].ip) < 7 || set.server[i].port == 0 ) continue; if ( !findstrinstr((char *)set.server[i].server_name, param) ) continue; if ( !set.use_current_name ) setLocalPlayerName( set.server[i].nickname ); strcpy( g_SAMP->szIP, set.server[i].ip ); g_SAMP->ulPort = set.server[i].port; setPassword( set.server[i].password ); joining_server = 1; return; } addMessageToChatWindow( "/m0d_fav_server <server name/part of server name>" ); return; }
void Client::setPromptList(const QStringList &texts){ QString prompt = Bang->translate(texts.at(0)); if(texts.length() >= 2) prompt.replace("%src", getPlayerName(texts.at(1))); if(texts.length() >= 3) prompt.replace("%dest", getPlayerName(texts.at(2))); if(texts.length() >= 4){ QString arg = Bang->translate(texts.at(3)); prompt.replace("%arg", arg); } if(texts.length() >= 5){ QString arg2 = Bang->translate(texts.at(4)); prompt.replace("%2arg", arg2); } prompt_doc->setHtml(prompt); }
void ArenaBattle::createHuman(UserInterface& display) { Weapon largeKnife("Large Knife", 60, 10); Armor leather("Leather Armor", 10); human.setGold(STARTING_GOLD); human.setPotionCount(STARTING_POTIONS); human.setWeapon(largeKnife); human.setArmor(leather); display.ask("What is thy name? "); getPlayerName(display.getInputBuffer()); std::cout << "[*] " << human.getName() << " is ready for adventure! " << std::endl; }
/* ** when a remote player leaves an arena game do this! ** ** @param player -- the one we need to clear ** @param quietly -- true means without any visible effects */ void clearPlayer(UDWORD player,bool quietly) { UDWORD i; STRUCTURE *psStruct,*psNext; debug(LOG_NET, "R.I.P. %s (%u). quietly is %s", getPlayerName(player), player, quietly ? "true":"false"); ingame.JoiningInProgress[player] = false; // if they never joined, reset the flag ingame.DataIntegrity[player] = false; (void)setPlayerName(player,""); //clear custom player name (will use default instead) for(i = 0;i<MAX_PLAYERS;i++) // remove alliances { alliances[player][i] = ALLIANCE_BROKEN; alliances[i][player] = ALLIANCE_BROKEN; } debug(LOG_DEATH, "killing off all droids for player %d", player); while(apsDroidLists[player]) // delete all droids { if(quietly) // don't show effects { killDroid(apsDroidLists[player]); } else // show effects { destroyDroid(apsDroidLists[player], gameTime); } } debug(LOG_DEATH, "killing off all structures for player %d", player); psStruct = apsStructLists[player]; while(psStruct) // delete all structs { psNext = psStruct->psNext; // FIXME: look why destroyStruct() doesn't put back the feature like removeStruct() does if(quietly || psStruct->pStructureType->type == REF_RESOURCE_EXTRACTOR) // don't show effects { removeStruct(psStruct, true); } else // show effects { destroyStruct(psStruct, gameTime); } psStruct = psNext; } return; }
void displayAIMessage(char *pStr, SDWORD from, SDWORD to) { char tmp[255]; if (isHumanPlayer(to)) //display text only if receiver is the (human) host machine itself { strcpy(tmp, getPlayerName(from)); strcat(tmp, ": "); // seperator strcat(tmp, pStr); // add message addConsoleMessage(tmp, DEFAULT_JUSTIFY, from); } }
//////////////////////////////// // at the end of every game. BOOL multiGameShutdown(void) { PLAYERSTATS st; debug(LOG_NET,"%s is shutting down.",getPlayerName(selectedPlayer)); sendLeavingMsg(); // say goodbye updateMultiStatsGames(); // update games played. st = getMultiStats(selectedPlayer); // save stats saveMultiStats(getPlayerName(selectedPlayer), getPlayerName(selectedPlayer), &st); // if we terminate the socket too quickly, then, it is possible not to get the leave message SDL_Delay(1000); // close game NETclose(); NETremRedirects(); if (ingame.numStructureLimits) { ingame.numStructureLimits = 0; free(ingame.pStructureLimits); ingame.pStructureLimits = NULL; } ingame.localJoiningInProgress = false; // Clean up ingame.localOptionsReceived = false; ingame.bHostSetup = false; // Dont attempt a host NetPlay.isHost = false; bMultiPlayer = false; // Back to single player mode bMultiMessages = false; selectedPlayer = 0; // Back to use player 0 (single player friendly) return true; }
void SummarizePlayer(int player_id) { for (int i = 0; i < player_database.size(); i++) { if (player_id == player_database[i].getId()) { cout << "" << endl; cout << "Player Name: " << getPlayerName(player_id) << endl; cout << "" << endl; cout << " " << setw(20) << left << "Game Name" << setw(20) << left << "Game IGN" << endl; PrintGame(player_id); cout << "" << endl; PrintFriends(player_id); cout << "" << endl; } } cout << "Total gamer points: " << sumGamerPoints(player_id); }
// recvGiftDroid() // We received a droid gift from another player. // NOTICE: the packet is already set-up for decoding via recvGift() // // \param from :player that sent us the droid // \param to :player that should be getting the droid static void recvGiftDroids(uint8_t from, uint8_t to, uint32_t droidID) { DROID *psDroid; if (IdToDroid(droidID, from, &psDroid)) { giftSingleDroid(psDroid, to); if (to == selectedPlayer) { CONPRINTF(ConsoleString, (ConsoleString, _("%s Gives you a %s"), getPlayerName(from), psDroid->aName)); } } else { debug(LOG_ERROR, "Bad droid id %u, from %u to %u", droidID, from, to); } }
// NOTICE: the packet is already set-up for decoding via recvGift() static void recvGiftStruct(uint8_t from, uint8_t to, uint32_t structID) { STRUCTURE *psStruct = IdToStruct(structID, from); if (psStruct) { syncDebugStructure(psStruct, '<'); giftSingleStructure(psStruct, to, false); syncDebugStructure(psStruct, '>'); if (to == selectedPlayer) { CONPRINTF(ConsoleString, (ConsoleString, _("%s Gives you a %s"), getPlayerName(from), objInfo(psStruct))); } } else { debug(LOG_ERROR, "Bad structure id %u, from %u to %u", structID, from, to); } }
// //////////////////////////////////////////////////////////////////////////// // give Power void giftPower(uint8_t from, uint8_t to, uint32_t amount, bool send) { if (send) { uint8_t giftType = POWER_GIFT; NETbeginEncode(NETgameQueue(selectedPlayer), GAME_GIFT); NETuint8_t(&giftType); NETuint8_t(&from); NETuint8_t(&to); NETuint32_t(&amount); NETend(); } else { int value = 0; if (from == ANYPLAYER && !NetPlay.bComms) { // basically cheating power, so we check that we are not in multiplayer addPower(to, amount); } else if (from == ANYPLAYER && NetPlay.bComms) { debug(LOG_WARNING, "Someone tried to cheat power in multiplayer - ignored!"); } else if (amount == 0) // the GUI option { value = getPower(from) / 3; usePower(from, value); addPower(to, value); } else // for scripts etc that can give precise amounts { value = MIN(getPower(from), amount); usePower(from, value); addPower(to, value); } if (from != ANYPLAYER && to == selectedPlayer) { CONPRINTF(ConsoleString, (ConsoleString, _("%s Gives You %d Power"), getPlayerName(from), value)); } } }