mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-01-14 07:38:00 +03:00
Add fallback place names if BotChatter.db is missing
This commit is contained in:
parent
1ae0091947
commit
8c14d05168
@ -540,8 +540,13 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex)
|
||||
else if (!Q_stricmp("UNDEFINED", token))
|
||||
placeCriteria = UNDEFINED_PLACE;
|
||||
else
|
||||
{
|
||||
placeCriteria = TheBotPhrases->NameToID(token);
|
||||
|
||||
if (!TheBotPhrases->IsValid() && placeCriteria == UNDEFINED_PLACE)
|
||||
placeCriteria = TheNavAreaGrid.NameToID(token);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -255,6 +255,8 @@ public:
|
||||
Place NameToID(const char *name) const;
|
||||
const char *IDToName(Place id) const;
|
||||
|
||||
bool IsValid() const { return !m_placeList.empty(); }
|
||||
|
||||
// given a name, return the associated phrase collection
|
||||
const BotPhrase *GetPhrase(const char *name) const;
|
||||
|
||||
|
@ -415,7 +415,11 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Radio)(const char *msg_id, const char *msg
|
||||
{
|
||||
// search the place name where is located the player
|
||||
const char *placeName = nullptr;
|
||||
if (AreRunningCZero() && TheBotPhrases)
|
||||
if ((
|
||||
#ifdef REGAMEDLL_ADD
|
||||
location_area_info.value ||
|
||||
#endif
|
||||
AreRunningCZero()) && TheBotPhrases)
|
||||
{
|
||||
Place playerPlace = TheNavAreaGrid.GetPlace(&pev->origin);
|
||||
const BotPhraseList *placeList = TheBotPhrases->GetPlaceList();
|
||||
@ -427,7 +431,11 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Radio)(const char *msg_id, const char *msg
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!placeName[0])
|
||||
placeName = TheNavAreaGrid.IDToName(playerPlace);
|
||||
}
|
||||
|
||||
if (placeName)
|
||||
ClientPrint(pEntity->pev, HUD_PRINTRADIO, NumAsString(entindex()), "#Game_radio_location", STRING(pev->netname), placeName, msg_verbose);
|
||||
else
|
||||
@ -10100,6 +10108,9 @@ void CBasePlayer::UpdateLocation(bool forceUpdate)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!placeName[0])
|
||||
placeName = TheNavAreaGrid.IDToName(playerPlace);
|
||||
}
|
||||
|
||||
if (!placeName[0] || (m_lastLocation[0] && !Q_strcmp(placeName, &m_lastLocation[1])))
|
||||
|
@ -3815,6 +3815,9 @@ void EditNavAreas(NavEditCmdType cmd)
|
||||
if (area->GetPlace())
|
||||
{
|
||||
const char *name = TheBotPhrases->IDToName(area->GetPlace());
|
||||
if (!TheBotPhrases->IsValid() && !name)
|
||||
name = TheNavAreaGrid.IDToName(area->GetPlace());
|
||||
|
||||
if (name)
|
||||
Q_strcpy(locName, name);
|
||||
else
|
||||
@ -4810,3 +4813,133 @@ Place CNavAreaGrid::GetPlace(const Vector *pos) const
|
||||
|
||||
return UNDEFINED_PLACE;
|
||||
}
|
||||
|
||||
static const char *g_pszDefaultPlaceNames[] =
|
||||
{
|
||||
"BombsiteA",
|
||||
"BombsiteB",
|
||||
"BombsiteC",
|
||||
"Hostages",
|
||||
"HostageRescueZone",
|
||||
"VipRescueZone",
|
||||
"CTSpawn",
|
||||
"TSpawn",
|
||||
"Bridge",
|
||||
"Middle",
|
||||
"House",
|
||||
"Apartment",
|
||||
"Apartments",
|
||||
"Market",
|
||||
"Sewers",
|
||||
"Tunnel",
|
||||
"Ducts",
|
||||
"Village",
|
||||
"Roof",
|
||||
"Upstairs",
|
||||
"Downstairs",
|
||||
"Basement",
|
||||
"Crawlspace",
|
||||
"Kitchen",
|
||||
"Inside",
|
||||
"Outside",
|
||||
"Tower",
|
||||
"WineCellar",
|
||||
"Garage",
|
||||
"Courtyard",
|
||||
"Water",
|
||||
"FrontDoor",
|
||||
"BackDoor",
|
||||
"SideDoor",
|
||||
"BackWay",
|
||||
"FrontYard",
|
||||
"BackYard",
|
||||
"SideYard",
|
||||
"Lobby",
|
||||
"Vault",
|
||||
"Elevator",
|
||||
"DoubleDoors",
|
||||
"SecurityDoors",
|
||||
"LongHall",
|
||||
"SideHall",
|
||||
"FrontHall",
|
||||
"BackHall",
|
||||
"MainHall",
|
||||
"FarSide",
|
||||
"Windows",
|
||||
"Window",
|
||||
"Attic",
|
||||
"StorageRoom",
|
||||
"ProjectorRoom",
|
||||
"MeetingRoom",
|
||||
"ConferenceRoom",
|
||||
"ComputerRoom",
|
||||
"BigOffice",
|
||||
"LittleOffice",
|
||||
"Dumpster",
|
||||
"Airplane",
|
||||
"Underground",
|
||||
"Bunker",
|
||||
"Mines",
|
||||
"Front",
|
||||
"Back",
|
||||
"Rear",
|
||||
"Side",
|
||||
"Ramp",
|
||||
"Underpass",
|
||||
"Overpass",
|
||||
"Stairs",
|
||||
"Ladder",
|
||||
"Gate",
|
||||
"GateHouse",
|
||||
"LoadingDock",
|
||||
"GuardHouse",
|
||||
"Entrance",
|
||||
"VendingMachines",
|
||||
"Loft",
|
||||
"Balcony",
|
||||
"Alley",
|
||||
"BackAlley",
|
||||
"SideAlley",
|
||||
"FrontRoom",
|
||||
"BackRoom",
|
||||
"SideRoom",
|
||||
"Crates",
|
||||
"Truck",
|
||||
"Bedroom",
|
||||
"FamilyRoom",
|
||||
"Bathroom",
|
||||
"LivingRoom",
|
||||
"Den",
|
||||
"Office",
|
||||
"Atrium",
|
||||
"Entryway",
|
||||
"Foyer",
|
||||
"Stairwell",
|
||||
"Fence",
|
||||
"Deck",
|
||||
"Porch",
|
||||
"Patio",
|
||||
"Wall"
|
||||
};
|
||||
|
||||
// Return fallback place name for given place id
|
||||
const char *CNavAreaGrid::IDToName(Place place) const
|
||||
{
|
||||
if (place <= 0 || place > ARRAYSIZE(g_pszDefaultPlaceNames))
|
||||
return nullptr;
|
||||
|
||||
return g_pszDefaultPlaceNames[place - 1];
|
||||
}
|
||||
|
||||
// Return place id for given place name
|
||||
Place CNavAreaGrid::NameToID(const char *name) const
|
||||
{
|
||||
for (unsigned int place = 0; place < ARRAYSIZE(g_pszDefaultPlaceNames); place++)
|
||||
{
|
||||
const char *placeName = g_pszDefaultPlaceNames[place];
|
||||
if (!Q_stricmp(placeName, name))
|
||||
return place + 1;
|
||||
}
|
||||
|
||||
return UNDEFINED_PLACE;
|
||||
}
|
||||
|
@ -505,6 +505,8 @@ public:
|
||||
|
||||
bool IsValid() const;
|
||||
Place GetPlace(const Vector *pos) const; // return radio chatter place for given coordinate
|
||||
Place NameToID(const char *name) const;
|
||||
const char *IDToName(Place id) const;
|
||||
|
||||
private:
|
||||
const float m_cellSize;
|
||||
|
@ -85,7 +85,10 @@ void PlaceDirectory::Save(int fd)
|
||||
// store entries
|
||||
for (auto &id : m_directory)
|
||||
{
|
||||
auto placeName = TheBotPhrases->IDToName(id);
|
||||
const char *placeName = TheBotPhrases->IDToName(id);
|
||||
|
||||
if (!TheBotPhrases->IsValid() && !placeName)
|
||||
placeName = TheNavAreaGrid.IDToName(id);
|
||||
|
||||
// store string length followed by string itself
|
||||
unsigned short len = (unsigned short)Q_strlen(placeName) + 1;
|
||||
@ -110,7 +113,11 @@ void PlaceDirectory::Load(SteamFile *file)
|
||||
file->Read(&len, sizeof(unsigned short));
|
||||
file->Read(placeName, len);
|
||||
|
||||
AddPlace(TheBotPhrases->NameToID(placeName));
|
||||
Place place = TheBotPhrases->NameToID(placeName);
|
||||
if (!TheBotPhrases->IsValid() && place == UNDEFINED_PLACE)
|
||||
place = TheNavAreaGrid.NameToID(placeName);
|
||||
|
||||
AddPlace(place);
|
||||
}
|
||||
}
|
||||
|
||||
@ -652,7 +659,12 @@ void LoadLocationFile(const char *filename)
|
||||
for (int i = 0; i < dirSize; i++)
|
||||
{
|
||||
locData = SharedParse(locData);
|
||||
directory.push_back(TheBotPhrases->NameToID(SharedGetToken()));
|
||||
|
||||
Place place = TheBotPhrases->NameToID(SharedGetToken());
|
||||
if (!TheBotPhrases->IsValid() && place == UNDEFINED_PLACE)
|
||||
place = TheNavAreaGrid.NameToID(SharedGetToken());
|
||||
|
||||
directory.push_back(place);
|
||||
}
|
||||
|
||||
// read places for each nav area
|
||||
|
Loading…
x
Reference in New Issue
Block a user