/** * Checks whether the 'next' tile is still part of the road same drive through * stop 'rs' in the same direction for the same vehicle. * @param rs the road stop tile to check against * @param next the 'next' tile to check * @return true if the 'next' tile is part of the road stop at 'next'. */ /* static */ bool RoadStop::IsDriveThroughRoadStopContinuation(TileIndex rs, TileIndex next) { return IsTileType(next, MP_STATION) && GetStationIndex(next) == GetStationIndex(rs) && GetStationType(next) == GetStationType(rs) && GetRoadStopDir(next) == GetRoadStopDir(rs) && IsDriveThroughStopTile(next); }
/* Will find a station identified using the NPFFindStationOrTileData */ static int32 NPFFindStationOrTile(AyStar *as, OpenListNode *current) { NPFFindStationOrTileData *fstd = (NPFFindStationOrTileData*)as->user_target; AyStarNode *node = ¤t->path.node; TileIndex tile = node->tile; if (fstd->station_index == INVALID_STATION && tile == fstd->dest_coords) return AYSTAR_FOUND_END_NODE; if (IsTileType(tile, MP_STATION) && GetStationIndex(tile) == fstd->station_index) { if (fstd->v->type == VEH_TRAIN) return AYSTAR_FOUND_END_NODE; assert(fstd->v->type == VEH_ROAD); /* Only if it is a valid station *and* we can stop there */ if (GetStationType(tile) == fstd->station_type && (fstd->not_articulated || IsDriveThroughStopTile(tile))) return AYSTAR_FOUND_END_NODE; } return AYSTAR_DONE; }
ALERROR CUniverse::InitLevelEncounterTables (void) // InitLevelEncounterTables // // Initializes the m_LevelEncounterTables array based on the encounter // tables of all the stations for each level. { m_LevelEncounterTables.RemoveAll(); for (int i = 1; i <= MAX_ITEM_LEVEL; i++) { CStructArray *pTable = new CStructArray(sizeof(SLevelEncounter), 8); for (int j = 0; j < GetStationTypeCount(); j++) { CStationType *pType = GetStationType(j); // Figure out the frequency of an encounter from this station based // on the frequency of the station at this level and the frequency // of encounters for this station. int iEncounterFreq = pType->GetEncounterFrequency(); int iStationFreq = pType->GetFrequencyByLevel(i); int iFreq = iEncounterFreq * iStationFreq / ftCommon; // Add to the table if (iFreq > 0) { pTable->ExpandArray(pTable->GetCount(), 1); SLevelEncounter *pEntry = (SLevelEncounter *)pTable->GetStruct(pTable->GetCount()-1); pEntry->iWeight = iFreq; pEntry->pBaseSovereign = pType->GetSovereign(); pEntry->pTable = pType->GetEncountersTable(); } } m_LevelEncounterTables.AppendObject(pTable, NULL); } return NOERROR; }