void sendChatMessage(udword users, char *message, uword player_index) { ChatPacket packetPtr; udword stringlength = strlen(message); udword sizeofpacket; wchar_t aWideStringP[MAX_CHAT_MESSAGE_LENGTH]; size_t aNumChars; dbgAssert(stringlength < MAX_CHAT_MESSAGE_LENGTH); dbgAssert(message[stringlength]==0); // now convert message, stringlength to widestring: aNumChars = mbstowcs(aWideStringP, message, stringlength+1); if (aNumChars != (size_t)-1) { aNumChars++; sizeofpacket = (sizeof(ChatPacket) - MAX_CHAT_MESSAGE_LENGTH*sizeof(wchar_t)) + (aNumChars<<1); //contruct packet by concatinating the message and the actual packet header packetPtr.packetheader.type = PACKETTYPE_CHAT; packetPtr.packetheader.frame = player_index; memcpy( packetPtr.message, aWideStringP, aNumChars<<1); packetPtr.users = (uword)users; packetPtr.messageType = CHAT_PACKET; SendChatPacketPacket(&packetPtr, sizeofpacket,users); } }
void AsyncLoop::removeCanceledRequests() { dbgAssert( m_lock.dbgHoldLock() ); if( !m_canceledRequests.empty() ) { for( size_t i = 0; i < m_canceledRequests.size(); ++i ) { CURL *const request = m_canceledRequests[ i ]; dbgAssert( request ); AsyncState *const asyncState = AsyncState::getFromCurl( request ); dbgAssert( asyncState ); m_canceledRequests[ i ] = NULL; if( !asyncState->isCompleted() ) { dbgVerify( m_socketPool.remove( asyncState->socket ) ); dbgVerify( curl_multi_remove_handle( m_multiCurl, request ) == CURLM_OK ); dbgAssert( m_runningRequestCount ); m_runningRequestCount--; asyncState->setCompleted(); } } m_canceledRequests.clear(); } }
lod *lodLevelGet(void *spaceObj, vector *camera, vector *ship) { real32 distance; SpaceObj *obj = (SpaceObj *)spaceObj; lodinfo *info = obj->staticinfo->staticheader.LOD; dbgAssert(info != NULL); //verify the LOD table exists vecSub(obj->cameraDistanceVector,*camera,*ship); obj->cameraDistanceSquared = distance = vecMagnitudeSquared(obj->cameraDistanceVector); #if LOD_SCALE_DEBUG if (lodDebugScaleFactor != 0.0f) { lodScaleFactor = lodDebugScaleFactor; } #endif if (distance > info->level[obj->currentLOD].bOff * lodScaleFactor) { //if drop a level of detail do { obj->currentLOD++; //go to lower level if (obj->currentLOD >= info->nLevels) { obj->currentLOD = info->nLevels-1; break; } } while (distance > info->level[obj->currentLOD].bOff * lodScaleFactor); } else { while (obj->currentLOD > 0 && distance < info->level[obj->currentLOD - 1].bOn * lodScaleFactor) { //if go higher level of detail obj->currentLOD--; //go to higher level } } dbgAssert(obj->currentLOD >= 0); dbgAssert(obj->currentLOD < info->nLevels); //verify we are within the available levels of detail #if LOD_PRINT_DISTANCE if (keyIsStuck(WKEY)) { keyClearSticky(WKEY); lodScaleFactor *= 0.99f; dbgMessagef("\nlodScaleFactor = %.3f", lodScaleFactor); } if (keyIsStuck(OKEY)) { keyClearSticky(OKEY); lodScaleFactor *= 1.01f; dbgMessagef("\nlodScaleFactor = %.3f", lodScaleFactor); } if (lodTuningMode) { obj->currentLOD = min(rndLOD, info->nLevels - 1); return(&info->level[min(rndLOD, info->nLevels - 1)]); } #endif return(&info->level[obj->currentLOD]); //return pointer to lod structure }
AITeamMove *aimCreateFancyGetShipsNoAdd(AITeam *team, ShipType shiptype, sbyte num_ships, AlternativeShips *alternatives, sdword priority, bool8 wait, bool8 remove) { TypeOfFormation formation = SAME_FORMATION; AITeamMove *newMove = (AITeamMove *)memAlloc(sizeof(AITeamMove), "getshipsmove", 0); dbgAssert(num_ships > 0); #ifndef HW_Release { sdword i; for (i=0;i<alternatives->numNextPicks;i++) { dbgAssert(alternatives->shipNumEquivNextPicks[i] > 0); } } #endif InitNewMove(newMove,MOVE_FANCYGETSHIPS,wait,remove,formation,Neutral,aimProcessFancyGetShips,NULL,aimCloseFancyGetShips); newMove->params.fancyGetShips.shipType = shiptype; newMove->params.fancyGetShips.numShips = num_ships; newMove->params.fancyGetShips.priority = priority; newMove->params.fancyGetShips.alternatives = *alternatives; newMove->params.fancyGetShips.doneVar = NULL; // aiplayerLog((aiIndex,"Created Fancy Getships Move")); return newMove; }
/*----------------------------------------------------------------------------- Name : liLayerColorAverage Description : Returns the average color of a layer Inputs : layer - layer to find average color of Outputs : Return : average color ----------------------------------------------------------------------------*/ color liLayerColorAverage(lilayer *layer) { udword red = 0, green = 0, blue = 0, alpha = 0, count, totalPixels; color *pColor; dbgAssert(layer->decompressed != NULL); dbgAssert(!bitTest(layer->flags, LFF_Channeled)); totalPixels = count = (layer->bounds.x1 - layer->bounds.x0) * (layer->bounds.y1 - layer->bounds.y0); pColor = layer->decompressed; while (count > 0) { red += colRed(*pColor); green += colGreen(*pColor); blue += colBlue(*pColor); alpha += colAlpha(*pColor); count--; pColor++; } red /= totalPixels; green /= totalPixels; blue /= totalPixels; alpha /= totalPixels; return(colRGBA(red, green, blue, alpha)); }
/*----------------------------------------------------------------------------- Name : aihKamikazeHealthLowHandler Description : Finds the ship who's health is low and kamikaze's it into the enemy Inputs : team - the team with the suicide bombers Outputs : Forces pilots to kill themselves in the name of greater good Return : void ----------------------------------------------------------------------------*/ void aihKamikazeHealthLowHandler(AITeam *team) { MaxSelection shipsToDie; udword i; ShipPtr ship; dbgAssert(team->shipList.selection->numShips); shipsToDie.numShips = 0; for (i=0;i<team->shipList.selection->numShips;i++) { ship = team->shipList.selection->ShipPtr[i]; if ((isShipOfClass(ship, CLASS_Fighter) || isShipOfClass(ship, CLASS_Corvette)) && ((100 * ship->health) < (team->curMove->events.healthLow.watchPercentage * ship->staticinfo->maxhealth))) { selSelectionAddSingleShip(&shipsToDie, ship); } } dbgAssert(shipsToDie.numShips); aiuWrapSetKamikaze((SelectCommand *)&shipsToDie); }
/*----------------------------------------------------------------------------- Name : liInsertChannelCompose Description : Takes a single channel from a source layer and sticks into a channel in desination buffer. Inputs : destBuffer - where to stick the channel. Must be same size as image. layerIndex - index of layer to get channel from image - image to get layer from sChannel - index of shource channel (0 = red, 1 = green, 2 = blue, 3 = alpha) dChannel - index of dest channel Outputs : copies channel from image to destBuffer Return : void ----------------------------------------------------------------------------*/ void liInsertChannelCompose(color *destBuffer, sdword layerIndex, layerimage *image, udword sChannel, udword dChannel) { lilayer *layer = &image->layers[layerIndex]; color *source, *dest; ubyte *pSource, *pDest; sdword width, height, sourceStride, count; #if LI_VERBOSE_LEVEL >= 2 dbgMessagef("\liInsertChannelCompose: inserting channel %d of layer %d ('%s') into channel %d", sChannel, layerIndex, layer->name, dChannel); #endif //LI_VERBOSE_LEVEL dbgAssert(layer->decompressed != NULL && ((layer->flags & LFF_Channeled) == 0)); dbgAssert(liBlender[layer->blendMode]); dbgAssert(sChannel < 4); dbgAssert(dChannel < 4); source = layer->decompressed; //first layer pixel dest = destBuffer + image->width * layer->bounds.y0 + layer->bounds.x0; //first dest pixel liClipLayer(layer, image, &source, &dest, &width, &height, &sourceStride); for (; height > 0; height--) { //for each scanline in our range pSource = (ubyte *)source + sChannel; //get byte-pointers pDest = (ubyte *)dest + dChannel; for (count = 0; count < width; count++, pDest += 4, pSource += 4) { //copy line of channel *pDest = *pSource; } dest += image->width; source += sourceStride; } }
void SetChannel(wchar_t *channel, wchar_t *description) { dbgAssert(wcslen(channel) <= MAX_CHANNEL_NAME_LEN); wcscpy(CurrentChannel,channel); dbgAssert(wcslen(description) <= MAX_CHANNEL_DESCRIPTION_LEN); wcscpy(CurrentChannelDescription,description); }
void AsyncLoop::cancelOp( CURL *request ) // nofail { dbgAssert( request ); AsyncState *const asyncState = AsyncState::getFromCurl( request ); // nofail dbgAssert( asyncState ); if( !asyncState->isCompleted() ) { // Append cancellation. { m_lock.claimLock(); ScopedExLock lock( &m_lock ); dbgAssert( m_canceledRequests.capacity() > m_pendingRequests.size() ); m_canceledRequests.push_back( request ); // nofail because it has enough capacity reserved by pendOp(..) m_hasPending = true; } m_socketPool.signal(); // nofail // Wait for the complete event. asyncState->completedEvent.wait(); // nofail } }
void aiePreFixAIEvents(struct AITeamMove *move) { if (move->events.interrupt.handler) { // convert pointer to offset into AIPlayer structure dbgAssert(move->events.interrupt.intvar); move->events.interrupt.intvar = ((ubyte *)move->events.interrupt.intvar) - ((ubyte *)fixingThisAIPlayer); dbgAssert(move->events.interrupt.intvar < sizeof(AIPlayer)); } move->events.gettingRocked.handler = aieHandlerToNum((aieHandlerSimple)move->events.gettingRocked.handler); move->events.enemyNearby.handler = aieHandlerToNum((aieHandlerSimple)move->events.enemyNearby.handler); move->events.enemyNotNearby.handler = aieHandlerToNum(move->events.enemyNotNearby.handler); move->events.firing.handler = aieHandlerToNum(move->events.firing.handler); move->events.disengage.handler = aieHandlerToNum(move->events.disengage.handler); move->events.healthLow.handler = aieHandlerToNum(move->events.healthLow.handler); move->events.healthHigh.handler = aieHandlerToNum(move->events.healthHigh.handler); move->events.numbersLow.handler = aieHandlerToNum(move->events.numbersLow.handler); move->events.numbersHigh.handler = aieHandlerToNum(move->events.numbersHigh.handler); move->events.fuelLow.handler = aieHandlerToNum(move->events.fuelLow.handler); move->events.fuelHigh.handler = aieHandlerToNum(move->events.fuelHigh.handler); move->events.shipDied.handler = aieHandlerToNum((aieHandlerSimple)move->events.shipDied.handler); move->events.teamDied.handler = aieHandlerToNum(move->events.teamDied.handler); move->events.interrupt.handler = aieHandlerToNum((aieHandlerSimple)move->events.interrupt.handler); }
void ProposeNewCaptain(void) { dbgAssert(captainProposal < sigsNumPlayers); captaincyLog(FALSE,"Cap:Proposing new captain %d",captainProposal); SendTransferCaptaincyPacket(-2,XFERCAP_CAPTAIN_PROPOSAL,captainProposal,NULL); captainProposal = (captainProposal + 1) % sigsNumPlayers; dbgAssert(captainProposal < sigsNumPlayers); }
/*----------------------------------------------------------------------------- Name : liChannelDecompressRLE Description : Decompress a single RLE channel into a RGBA buffer Inputs : buffer - where to decode image to scanLength - array of number of bytes per scanline data - RLE compressed data width - width of buffer height - height of buffer offset - color-element offset (0..3) Outputs : fills buffer with decompressed channel data Return : void ----------------------------------------------------------------------------*/ void liChannelDecompressRLE(ubyte *buffer, uword *scanLength, ubyte *data, sdword width, sdword height, sdword offset) { sdword index, x, y; #if LI_ERROR_CHECKING sdword nRead; #endif sbyte opCode; buffer += offset; for (y = 0; y < height; y++) { #if LI_ERROR_CHECKING nRead = 0; #endif for (x = 0; x < width;) { opCode = *data; data++; #if LI_ERROR_CHECKING nRead++; #endif if (opCode >= 0) { //literal run for (index = 0; index < (sdword)opCode + 1; index++) { *buffer = (ubyte)*data; buffer += 4; data++; #if LI_ERROR_CHECKING nRead++; #endif x++; } } else if (opCode > -128) { opCode = -opCode; for (index = 0; index < (sdword)opCode + 1; index++) { *buffer = (ubyte)*data; buffer += 4; x++; } data++; #if LI_ERROR_CHECKING nRead++; #endif } } // buffer += (width - x) * 4; //skip straggler pixels at end #if LI_ERROR_CHECKING dbgAssert(x == width); dbgAssert(nRead == scanLength[y]); #endif } }
void AcknowledgeNewCaptain(sdword newcaptainIndex) { captaincyLog(FALSE,"Cap:New captain acknowledged %d",newcaptainIndex); dbgAssert(newcaptainIndex < sigsNumPlayers); captainIndex = newcaptainIndex; receiveSyncPacketsFrom = captainIndex; explicitlyRequestingPackets = FALSE; // captaincy transferred, cancel explicitly requested packets dbgAssert(!IAmCaptain); CaptaincyChangedNotify(); }
void MiningBaseDied(Ship *ship) { Ship *deleteme; Node *node; MiningBaseSpec *spec = (MiningBaseSpec *)ship->ShipSpecifics; dbgAssert(ship->shiptype == MiningBase); if (ship->flags & SOF_NISShip) { return; } if (spec->dontRecurseKill) { return; } // first pass: Set all other MiningBases to dontRecurseKill so we don't get weird recursion for (node = universe.ShipList.head; node != NULL; node = node->next) { deleteme = (Ship *)listGetStructOfNode(node); dbgAssert(deleteme->objtype == OBJ_ShipType); if ((deleteme->shiptype == MiningBase) && (deleteme != ship) && ((deleteme->flags & (SOF_Dead|SOF_NISShip)) == 0)) { spec = (MiningBaseSpec *)deleteme->ShipSpecifics; spec->dontRecurseKill = TRUE; } } // delete all other mining bases for (node = universe.ShipList.head; node != NULL; node = node->next) { deleteme = (Ship *)listGetStructOfNode(node); dbgAssert(deleteme->objtype == OBJ_ShipType); if ((deleteme->shiptype == MiningBase) && (deleteme != ship) && ((deleteme->flags & (SOF_Dead|SOF_NISShip)) == 0)) { deleteme->howDidIDie = ship->howDidIDie; deleteme->whoKilledMe = ship->whoKilledMe; univDeleteDeadShip(deleteme,EDT_AccumDamage); listRemoveNode(&deleteme->shiplink); listRemoveNode(&deleteme->impactablelink); #if ETG_DISABLEABLE if (!etgEffectsEnabled) { univWipeShipOutOfExistence(deleteme); } #endif } } }
void AsyncCurl::pendOp( AsyncMan *opMan ) { dbgAssert( opMan ); dbgAssert( !m_asyncState->asyncLoop ); dbgAssert( !AsyncState::getFromCurl( m_curl ) || AsyncState::getFromCurl( m_curl ) == m_asyncState ); AsyncState::setToCurl( m_curl, m_asyncState ); AsyncLoop::pendOp( opMan->head(), m_curl, opMan->connectionsPerThread() ); dbgAssert( m_asyncState->asyncLoop ); }
void TransferCaptaincyUpdate(void) { udword numPackets; udword sizeofPacket; ubyte *packet; ubyte *copypacket; if ((transferCaptaincyDisabled) || (sigsNumPlayers < 2)) { return; } TimeoutTimerUpdateAll(); LockQueue(&ProcessCaptaincyPktQ); numPackets = queueNumberEntries(ProcessCaptaincyPktQ); while (numPackets > 0) { sizeofPacket = Dequeue(&ProcessCaptaincyPktQ,&packet); dbgAssert(sizeofPacket > 0); copypacket = memAlloc(sizeofPacket,"cp(miscpacket)",Pyrophoric); memcpy(copypacket,packet,sizeofPacket); UnLockQueue(&ProcessCaptaincyPktQ); dbgAssert(((HWPacketHeader *)copypacket)->type == PACKETTYPE_TRANSFERCAPTAINCY); ProcessTransferCaptaincyPacket((TransferCaptaincyPacket *)copypacket); memFree(copypacket); LockQueue(&ProcessCaptaincyPktQ); numPackets = queueNumberEntries(ProcessCaptaincyPktQ); } UnLockQueue(&ProcessCaptaincyPktQ); #if 0 if (numPackets == 0) { UnLockQueue(&ProcessCaptaincyPktQ); } else { sizeofPacket = Dequeue(&ProcessCaptaincyPktQ,&packet); dbgAssert(sizeofPacket > 0); copypacket = memAlloc(sizeofPacket,"cp(miscpacket)",Pyrophoric); memcpy(copypacket,packet,sizeofPacket); UnLockQueue(&ProcessCaptaincyPktQ); dbgAssert(((HWPacketHeader *)copypacket)->type == PACKETTYPE_TRANSFERCAPTAINCY); ProcessTransferCaptaincyPacket((TransferCaptaincyPacket *)copypacket); memFree(copypacket); } #endif }
sdword aimProcessLaunch(AITeam *team) { AITeamMove *thisMove = team->curMove; SelectCommand *selection = team->shipList.selection; Ship *ship; Ship *shipIAmInside; sdword i; if (selection->numShips == 0) { return FALSE; } ship = selection->ShipPtr[0]; shipIAmInside = univFindShipIAmInside(ship); if (shipIAmInside != NULL) { SelectCommand *selectcopy = memAlloc(sizeofSelectCommand(selection->numShips),"selectcopy",0); selectcopy->numShips = 0; dbgAssert(!thisMove->processing); for (i=0;i<selection->numShips;i++) { if (univAmIInsideThisShip(selection->ShipPtr[i],shipIAmInside)) { selectcopy->ShipPtr[selectcopy->numShips++] = selection->ShipPtr[i]; } } dbgAssert(selectcopy->numShips > 0); // Falko, don't replace this with aiuWrap because many ships in selectcopy are hidden, but this is okay in this case clWrapLaunchMultipleShips(&universe.mainCommandLayer,selectcopy,shipIAmInside); memFree(selectcopy); thisMove->processing = TRUE; return TRUE; } else if ((ship->specialFlags & SPECIAL_STAY_TILL_EXPLICITLAUNCH) && (ShipIsWaitingForSoftLaunch(ship))) { // we're on the ASF, so let's do a "soft" launch for (i=0;i<selection->numShips;i++) { bitClear(selection->ShipPtr[i]->specialFlags,SPECIAL_STAY_TILL_EXPLICITLAUNCH); } thisMove->processing = TRUE; return TRUE; } return FALSE; }
/*----------------------------------------------------------------------------- Name : titanGameStartup Description : initializes the titan game networking interface variables. Inputs : none Outputs : none Return : void ----------------------------------------------------------------------------*/ void titanGameStartup(void) { tpChannelList.numChannels = 0; tpChannelList.newDataArrived = FALSE; tpChannelList.mutex = (void *)CreateMutex(NULL,FALSE,NULL); dbgAssert(tpChannelList.mutex != NULL); tpServerList.numServers = 0; tpServerList.newDataArrived = FALSE; tpServerList.mutex = (void *)CreateMutex(NULL,FALSE,NULL); dbgAssert(tpServerList.mutex != NULL); titanResetGameCreated(); }
/*----------------------------------------------------------------------------- Name : spScenarioBitmap Description : Inputs : Outputs : Return : ----------------------------------------------------------------------------*/ void spScenarioBitmap(featom *atom, regionhandle region) { rectangle textureRect; sdword index, y; fonthandle oldFont; textureRect.x0 = region->rect.x0 + SCP_TEXTURE_INSET; textureRect.y0 = region->rect.y0 + SCP_TEXTURE_INSET; textureRect.x1 = region->rect.x1 - SCP_TEXTURE_INSET; textureRect.y1 = region->rect.y1 - SCP_TEXTURE_INSET; //draw the bitmap... if (scenarioTexture != TR_InvalidInternalHandle) { if (glcActive()) { glcRectSolidTexturedScaled2(&textureRect, spTextureWidth, spTextureHeight, spTextureData, NULL, TRUE); } else { trRGBTextureMakeCurrent(scenarioTexture); rndPerspectiveCorrection(FALSE); primRectSolidTextured2(&textureRect); //draw the bitmap } feStaticRectangleDraw(region); //draw a border } //draw the description text... if (spDescription != NULL) { //if there is description text dbgAssert(spDescriptionFont != FONT_InvalidFontHandle); oldFont = fontMakeCurrent(spDescriptionFont); //set the font if (spDescriptionShadow) { //optionally enable dropshadow fontShadowSet(FS_SE, colBlack); } for (index = 0, y = textureRect.y0; index < spNDescriptionLines; index++) { //draw each line dbgAssert(spDescriptionLines[index] != NULL); if (y + fontHeight(" ") >= textureRect.y1) { //if this line will extend off bottom of region break; } fontPrint(textureRect.x0, y, spDescriptionColor, spDescriptionLines[index]); y += fontHeight(" ") + 1; } fontShadowSet(FS_NONE, colBlack); fontMakeCurrent(oldFont); } }
void taskStartAsync( TaskFn *taskFn, void *arg, TaskCtrl *pctrl ) { dbgAssert( taskFn ); dbgAssert( pctrl ); DWORD id; HANDLE const h = CreateThread( 0, 0, taskFn, arg, 0, &id ); if( !h ) throwSystemError( GetLastError(), "starttask" ); pctrl->reset( h ); }
void taskStartAsync( TaskFn *taskFn, void *arg, TaskCtrl *pctrl ) { dbgAssert( taskFn ); dbgAssert( pctrl ); pthread_t thd = 0; if( int err = pthread_create( &thd, 0, taskFn, arg ) ) throwSystemError( err, "starttask" ); dbgAssert( thd ); pctrl->reset( thd ); }
void LaunchDrone(Ship *ship,Ship *drone) { DroneSpec *dronespec = (DroneSpec *)drone->ShipSpecifics; dbgAssert(ship->shiptype == DDDFrigate); dbgAssert(drone->shiptype == Drone); dockPrepareSingleShipForLaunch(drone,ship); dockInitShipForLaunch(drone); dronespec->droneState = DRONESTATE_LAUNCHING; InitShipAI(drone,TRUE); }
void AsyncLoop::addSocket( AsyncState *asyncState, curl_socket_t socket, int what ) // nofail { dbgAssert( asyncState ); dbgAssert( !asyncState->isCompleted() ); CASSERT( SA_POLL_IN == CURL_POLL_IN ); CASSERT( SA_POLL_OUT == CURL_POLL_OUT ); // Assign the socket to the socketReady signal. CASSERT( sizeof( curl_socket_t ) == sizeof( SocketHandle ) ); asyncState->socket = ( SocketHandle )( socket ); m_socketPool.add( asyncState->socket, what ); // nofail }
/*----------------------------------------------------------------------------- Name : rmSetTechDependCB Description : sets the technology dependancies based on a list of strings Inputs : standard callback inputs Outputs : none Return : void ----------------------------------------------------------------------------*/ void rmSetTechDependCB(char *directory, char *field, void *dataToFillIn) { sdword index; char temp[64]; TechnologyType techtype, techset; udword mask=0; for (index=0; *field != ' '; index++,field++) { temp[index]=*field; } temp[index]=0; while ((*field == ' ') && (*field != 0)) field++; if (*field == 0) return; if (*field != 0) { RemoveCommasFromString(field); techset = StrToTechType(temp); dbgAssert(techset!=-1); while (*field != 0) { for (index=0; (*field != ' ')&&(*field != 0); index++,field++) { temp[index]=*field; } temp[index]=0; techtype = StrToTechType(temp); dbgAssert(techtype != -1); mask |= TechToBit(techtype); while (*field == ' ') field++; } } ((udword *)dataToFillIn)[techset] = mask; }
TaskResult TASKAPI AsyncLoop::asyncLoopTask( void *arg ) { dbgAssert( arg ); static_cast< AsyncLoop * >( arg )->asyncLoop(); return 0; }
void gpOverwriteYes(char *name, featom *atom) { dbgAssert(overwritefilename[0] != 0); if (overwriteRecGame) { overwriteRecGame = FALSE; recPackInGameStartCB(overwritefilename); feAllScreensDelete(); if (!multiPlayerGame) { universePause = FALSE; // unpause game } } else { if (SaveGame(overwritefilename)) clCommandMessage(strGetString(strSavedGame)); else clCommandMessage(strGetString(strPatchUnableWriteFile)); feAllScreensDelete(); if (!multiPlayerGame) { universePause = FALSE; // unpause game } } }
void GenericDefenderStaticInit(char *directory,char *filename,struct ShipStaticInfo *statinfo) { udword i; GenericDefenderStatics *defenderstat; switch (statinfo->shiptype) { case LightDefender: defenderstat = (statinfo->shiprace == R1) ? &LightDefenderStaticRace1 : &LightDefenderStaticRace2; break; case HeavyDefender: defenderstat = (statinfo->shiprace == R1) ? &HeavyDefenderStaticRace1 : &HeavyDefenderStaticRace2; break; default: dbgAssert(FALSE); } statinfo->custstatinfo = defenderstat; for(i=0;i<NUM_TACTICS_TYPES;i++) { defenderstat->gunRange[i] = statinfo->bulletRange[i]; defenderstat->tooCloseRange[i] = statinfo->minBulletRange[i] * 0.9f; } defenderstat->CIRCLE_RIGHT_VELOCITY = 20.0f; defenderstat->CIRCLE_RIGHT_THRUST = 0.1f; scriptSetStruct(directory,filename,DefenderStaticScriptTable,(ubyte *)defenderstat); }
/*----------------------------------------------------------------------------- Name : lodFree Description : frees LOD Inputs : Outputs : Return : ----------------------------------------------------------------------------*/ void lodFree(lodinfo *LOD) { sdword i; void *pData; for (i=0;i<LOD->nLevels;i++) { pData = LOD->level[i].pData; switch (LOD->level[i].flags) { case LT_Mesh: if ((pData != defaultmesh) && (pData != NULL)) { meshFree((meshdata *)pData); } dbgAssert(LOD->level[i].hBindings != NULL); meshBindingListDelete(LOD->level[i].hBindings); break; default: // later add other stuff you want to free such as sprites Luke. break; } } memFree(LOD); }
void titanUpdatePlayerCB(Address *address, const void *blob, unsigned short bloblen) { udword i; PlayerJoinInfo *pinfo=(PlayerJoinInfo *)blob; dbgAssert(bloblen == sizeof(PlayerJoinInfo)); for (i=0;i<tpGameCreated.numPlayers;i++) { if (AddressesAreEqual(tpGameCreated.playerInfo[i].address,*address)) { tpGameCreated.playerInfo[i].baseColor = pinfo->baseColor; tpGameCreated.playerInfo[i].stripeColor = pinfo->stripeColor; tpGameCreated.playerInfo[i].colorsPicked = pinfo->colorsPicked; tpGameCreated.playerInfo[i].race = pinfo->race; titanBroadcastPacket(TITANMSGTYPE_UPDATEGAMEDATA, &tpGameCreated, sizeof(tpGameCreated)); if (LANGame) lgUpdateGameInfo(); else mgUpdateGameInfo(); } } }
/*----------------------------------------------------------------------------- Name : aioCreateSpecialDefense Description : Creates a team to do some cloaking Inputs : team - the team to do the cloaking Outputs : Creates some new moves Return : void ----------------------------------------------------------------------------*/ void aioCreateSpecialDefense(AITeam *team, ShipType type) { AITeamMove *move; ShipStaticInfo *gravstatics; aiplayerLog((aiIndex, "%x Issuing Special Defense Order", team)); aimCreateGetShips(team, type, 1, 0, TRUE, FALSE); move = aimCreateSpecialDefense(team, TRUE, FALSE); if (type == GravWellGenerator) { gravstatics = GetShipStaticInfo(GravWellGenerator, R1); if (gravstatics) { aieHandlerSetEnemyNearby(move, (((GravWellGeneratorStatics *) gravstatics->custstatinfo)->GravWellRadius)*0.8, FALSE, aihGravWellEnemyNearbyHandler); aieHandlerSetTeamDied(move, aihRemoveTeamDiedHandler); } else { dbgAssert(FALSE); } } aimCreateMoveDone(team, FALSE, FALSE); }