/* Update routine for features */ void featureUpdate(FEATURE *psFeat) { syncDebugFeature(psFeat, '<'); // update the visibility for the feature processVisibilityLevel((BASE_OBJECT *)psFeat); syncDebugFeature(psFeat, '>'); }
/* Update routine for features */ void featureUpdate(FEATURE *psFeat) { syncDebugFeature(psFeat, '<'); /* Update the periodical damage data */ if (psFeat->periodicalDamageStart != 0 && psFeat->periodicalDamageStart != gameTime - deltaGameTime) // -deltaGameTime, since projectiles are updated after features. { // The periodicalDamageStart has been set, but is not from the previous tick, so we must be out of the periodical damage. psFeat->periodicalDamage = 0; // Reset periodical damage done this tick. // Finished periodical damaging psFeat->periodicalDamageStart = 0; } syncDebugFeature(psFeat, '>'); }
// /////////////////////////////////////////////////////////////// // receive splattered artifacts void recvMultiPlayerRandomArtifacts(NETQUEUE queue) { int count, i; uint8_t quantity, player; uint32_t tx,ty; uint32_t ref; FEATURE_TYPE type = FEAT_TREE; // Dummy initialisation. FEATURE *pF; NETbeginDecode(queue, GAME_ARTIFACTS); NETuint8_t(&quantity); NETenum(&type); debug(LOG_FEATURE, "receiving %u artifact(s) type: (%s)", quantity, feature_names[type]); for (i = 0; i < numFeatureStats && asFeatureStats[i].subType != type; i++) {} for (count = 0; count < quantity; count++) { MAPTILE *psTile; NETuint32_t(&tx); NETuint32_t(&ty); NETuint32_t(&ref); NETuint8_t(&player); if (tx == INVALID_XY) { continue; } else if (!tileOnMap(tx, ty)) { debug(LOG_ERROR, "Bad tile coordinates (%u,%u)", tx, ty); continue; } psTile = mapTile(tx, ty); if (!psTile || psTile->psObject != NULL) { debug(LOG_ERROR, "Already something at (%u,%u)!", tx, ty); continue; } pF = buildFeature((asFeatureStats + i), world_coord(tx), world_coord(ty), false); if (pF) { pF->id = ref; pF->player = player; syncDebugFeature(pF, '+'); } else { debug(LOG_ERROR, "Couldn't build feature %u for player %u ?", ref, player); } } NETend(); }
bool addOilDrum(uint8_t count) { syncDebug("Adding %d oil drums.", count); int featureIndex; for (featureIndex = 0; featureIndex < numFeatureStats && asFeatureStats[featureIndex].subType != FEAT_OIL_DRUM; ++featureIndex) {} if (featureIndex >= numFeatureStats) { debug(LOG_WARNING, "No oil drum feature!"); return false; // Return value ignored. } for (unsigned n = 0; n < count; ++n) { uint32_t x, y; for (int i = 0; i < 3; ++i) // try three times { // Between 10 and mapwidth - 10 x = gameRand(mapWidth - 20) + 10; y = gameRand(mapHeight - 20) + 10; if (pickATileGen(&x, &y, LOOK_FOR_EMPTY_TILE, zonedPAT)) { break; } x = INVALID_XY; } if (x == INVALID_XY) { syncDebug("Did not find location for oil drum."); debug(LOG_FEATURE, "Unable to find a free location."); continue; } FEATURE *pF = buildFeature(&asFeatureStats[featureIndex], world_coord(x), world_coord(y), false); if (pF) { pF->player = ANYPLAYER; syncDebugFeature(pF, '+'); } else { debug(LOG_ERROR, "Couldn't build oil drum?"); } } return true; }
// //////////////////////////////////////////////////////////////////////////// // add an artifact on destruction if required. void technologyGiveAway(const STRUCTURE *pS) { // If a fully built factory (or with modules under construction) which is our responsibility got destroyed if (pS->pStructureType->type == REF_FACTORY && (pS->status == SS_BUILT || pS->currentBuildPts >= pS->body)) { syncDebug("Adding artefact."); } else { syncDebug("Not adding artefact."); return; } int featureIndex; for (featureIndex = 0; featureIndex < numFeatureStats && asFeatureStats[featureIndex].subType != FEAT_GEN_ARTE; ++featureIndex) {} if (featureIndex >= numFeatureStats) { debug(LOG_WARNING, "No artefact feature!"); return; } uint32_t x = map_coord(pS->pos.x), y = map_coord(pS->pos.y); if (!pickATileGen(&x, &y, LOOK_FOR_EMPTY_TILE, zonedPAT)) { syncDebug("Did not find location for oil drum."); debug(LOG_FEATURE, "Unable to find a free location."); return; } FEATURE *pF = buildFeature(&asFeatureStats[featureIndex], world_coord(x), world_coord(y), false); if (pF) { pF->player = pS->player; syncDebugFeature(pF, '+'); } else { debug(LOG_ERROR, "Couldn't build artefact?"); } }