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); } } }
/** Draw the droids and structure positions on the radar. */ static void DrawRadarObjects() { UBYTE clan; PIELIGHT playerCol; PIELIGHT flashCol; int x, y; /* Show droids on map - go through all players */ for (clan = 0; clan < MAX_PLAYERS; clan++) { DROID *psDroid; //see if have to draw enemy/ally color if (bEnemyAllyRadarColor) { if (clan == selectedPlayer) { playerCol = colRadarMe; } else { playerCol = (aiCheckAlliances(selectedPlayer, clan) ? colRadarAlly : colRadarEnemy); } } else { //original 8-color mode STATIC_ASSERT(MAX_PLAYERS <= ARRAY_SIZE(clanColours)); playerCol = clanColours[getPlayerColour(clan)]; } STATIC_ASSERT(MAX_PLAYERS <= ARRAY_SIZE(flashColours)); flashCol = flashColours[getPlayerColour(clan)]; /* Go through all droids */ for (psDroid = apsDroidLists[clan]; psDroid != NULL; psDroid = psDroid->psNext) { if (psDroid->pos.x < world_coord(scrollMinX) || psDroid->pos.y < world_coord(scrollMinY) || psDroid->pos.x >= world_coord(scrollMaxX) || psDroid->pos.y >= world_coord(scrollMaxY)) { continue; } if (psDroid->visible[selectedPlayer] || (bMultiPlayer && alliancesSharedVision(game.alliance) && aiCheckAlliances(selectedPlayer, psDroid->player))) { int x = psDroid->pos.x / TILE_UNITS; int y = psDroid->pos.y / TILE_UNITS; size_t pos = (x - scrollMinX) + (y - scrollMinY) * radarTexWidth; ASSERT(pos * sizeof(*radarBuffer) < radarBufferSize, "Buffer overrun"); if (clan == selectedPlayer && gameTime - psDroid->timeLastHit < HIT_NOTIFICATION) { radarBuffer[pos] = flashCol.rgba; } else { radarBuffer[pos] = playerCol.rgba; } } } } /* Do the same for structures */ for (x = scrollMinX; x < scrollMaxX; x++) { for (y = scrollMinY; y < scrollMaxY; y++) { MAPTILE *psTile = mapTile(x, y); STRUCTURE *psStruct; size_t pos = (x - scrollMinX) + (y - scrollMinY) * radarTexWidth; ASSERT(pos * sizeof(*radarBuffer) < radarBufferSize, "Buffer overrun"); if (!TileHasStructure(psTile)) { continue; } psStruct = (STRUCTURE *)psTile->psObject; clan = psStruct->player; //see if have to draw enemy/ally color if (bEnemyAllyRadarColor) { if (clan == selectedPlayer) { playerCol = colRadarMe; } else { playerCol = (aiCheckAlliances(selectedPlayer, clan) ? colRadarAlly : colRadarEnemy); } } else { //original 8-color mode playerCol = clanColours[getPlayerColour(clan)]; } flashCol = flashColours[getPlayerColour(clan)]; if (psStruct->visible[selectedPlayer] || (bMultiPlayer && alliancesSharedVision(game.alliance) && aiCheckAlliances(selectedPlayer, psStruct->player))) { if (clan == selectedPlayer && gameTime - psStruct->timeLastHit < HIT_NOTIFICATION) { radarBuffer[pos] = flashCol.rgba; } else { radarBuffer[pos] = playerCol.rgba; } } } } }
bool stageThreeInitialise(void) { STRUCTURE *psStr; UDWORD i; DROID *psDroid; debug(LOG_WZ, "== stageThreeInitalise =="); loopMissionState = LMS_NORMAL; if(!InitRadar()) // After resLoad cause it needs the game palette initialised. { return false; } // reset the clock to normal speed gameTimeResetMod(); if (!init3DView()) // Initialise 3d view stuff. After resLoad cause it needs the game palette initialised. { return false; } effectResetUpdates(); initLighting(0, 0, mapWidth, mapHeight); pie_InitLighting(); if(bMultiPlayer) { // FIXME Is this really needed? debug( LOG_WZ, "multiGameInit()\n" ); multiGameInit(); cmdDroidMultiExpBoost(true); } preProcessVisibility(); // Load any stored templates; these need to be available ASAP initTemplates(); prepareScripts(); if (!fpathInitialise()) { return false; } mapInit(); clustInitialise(); gridReset(); //if mission screen is up, close it. if(MissionResUp) { intRemoveMissionResultNoAnim(); } // Re-inititialise some static variables. driveInitVars(false); resizeRadar(); setAllPauseStates(false); /* decide if we have to create teams, ONLY in multiplayer mode!*/ if (bMultiPlayer && alliancesSharedVision(game.alliance)) { createTeamAlliances(); /* Update ally vision for pre-placed structures and droids */ for(i=0;i<MAX_PLAYERS;i++) { if(i != selectedPlayer) { /* Structures */ for(psStr=apsStructLists[i]; psStr; psStr=psStr->psNext) { if(aiCheckAlliances(psStr->player,selectedPlayer)) visTilesUpdate((BASE_OBJECT *)psStr); } /* Droids */ for(psDroid=apsDroidLists[i]; psDroid; psDroid=psDroid->psNext) { if(aiCheckAlliances(psDroid->player,selectedPlayer)) visTilesUpdate((BASE_OBJECT *)psDroid); } } } } // ffs JS (and its a global!) if (getLevelLoadType() != GTYPE_SAVE_MIDMISSION) { eventFireCallbackTrigger((TRIGGER_TYPE)CALL_GAMEINIT); triggerEvent(TRIGGER_GAME_INIT); } intAddPower(); return true; }
bool stageThreeInitialise() { STRUCTURE *psStr; UDWORD i; DROID *psDroid; bool fromSave = (getSaveGameType() == GTYPE_SAVE_START || getSaveGameType() == GTYPE_SAVE_MIDMISSION); debug(LOG_WZ, "== stageThreeInitialise =="); loopMissionState = LMS_NORMAL; if (!InitRadar()) // After resLoad cause it needs the game palette initialised. { return false; } // reset the clock to normal speed gameTimeResetMod(); if (!init3DView()) // Initialise 3d view stuff. After resLoad cause it needs the game palette initialised. { return false; } effectResetUpdates(); initLighting(0, 0, mapWidth, mapHeight); pie_InitLighting(); if (fromSave) { // these two lines are the biggest hack in the world. // the reticule seems to get detached from 'reticuleup' // this forces it back in sync... intRemoveReticule(); intAddReticule(); } if (bMultiPlayer) { if (!fromSave) { multiGameInit(); } initTemplates(); } preProcessVisibility(); prepareScripts(getLevelLoadType() == GTYPE_SAVE_MIDMISSION || getLevelLoadType() == GTYPE_SAVE_START); if (!fpathInitialise()) { return false; } mapInit(); gridReset(); //if mission screen is up, close it. if (MissionResUp) { intRemoveMissionResultNoAnim(); } // Re-inititialise some static variables. resizeRadar(); setAllPauseStates(false); /* decide if we have to create teams, ONLY in multiplayer mode!*/ if (bMultiPlayer && alliancesSharedVision(game.alliance)) { createTeamAlliances(); /* Update ally vision for pre-placed structures and droids */ for (i = 0; i < MAX_PLAYERS; i++) { if (i != selectedPlayer) { /* Structures */ for (psStr = apsStructLists[i]; psStr; psStr = psStr->psNext) { if (aiCheckAlliances(psStr->player, selectedPlayer)) { visTilesUpdate((BASE_OBJECT *)psStr); } } /* Droids */ for (psDroid = apsDroidLists[i]; psDroid; psDroid = psDroid->psNext) { if (aiCheckAlliances(psDroid->player, selectedPlayer)) { visTilesUpdate((BASE_OBJECT *)psDroid); } } } } } countUpdate(); if (getLevelLoadType() != GTYPE_SAVE_MIDMISSION) { if (getDebugMappingStatus()) { triggerEventCheatMode(true); } eventFireCallbackTrigger((TRIGGER_TYPE)CALL_GAMEINIT); triggerEvent(TRIGGER_GAME_INIT); } return true; }