Add zone store

This commit is contained in:
Akkadius
2020-04-19 03:05:15 -05:00
parent 6a51bcf8fd
commit ebda1cf601
9 changed files with 352 additions and 172 deletions
+4 -1
View File
@@ -142,6 +142,7 @@ SET(zone_sources
zone_config.cpp
zonedb.cpp
zone_reload.cpp
zone_store.cpp
zoning.cpp
)
@@ -249,7 +250,9 @@ SET(zone_headers
zone_config.h
zonedb.h
zonedump.h
zone_reload.h )
zone_reload.h
zone_store.h
)
ADD_EXECUTABLE(zone ${zone_sources} ${zone_headers})
+25 -19
View File
@@ -1,20 +1,22 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#define DONT_SHARED_OPCODES
#define PLATFORM_ZONE 1
@@ -93,6 +95,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#else
#include <pthread.h>
#include "../common/unix.h"
#include "zone_store.h"
#endif
@@ -101,6 +104,7 @@ extern volatile bool is_zone_loaded;
EntityList entity_list;
WorldServer worldserver;
ZoneStore zone_store;
uint32 numclients = 0;
char errorname[32];
extern Zone* zone;
@@ -318,6 +322,8 @@ int main(int argc, char** argv) {
content_db.LoadZoneNames();
database.zonename_array = content_db.zonename_array;
zone_store.LoadZonesStore();
LogInfo("Loading items");
if (!database.LoadItems(hotfix_name)) {
LogError("Loading items failed!");
@@ -373,7 +379,7 @@ int main(int argc, char** argv) {
LogInfo("Loading commands");
int retval = command_init();
if (retval<0)
if (retval < 0)
LogError("Command loading failed");
else
LogInfo("{} commands loaded", retval);
@@ -466,7 +472,7 @@ int main(int argc, char** argv) {
if (!strlen(zone_name) || !strcmp(zone_name, ".")) {
LogInfo("Entering sleep mode");
}
else if (!Zone::Bootup(content_db.GetZoneID(zone_name), instance_id, true)) {
else if (!Zone::Bootup(ZoneID(zone_name), instance_id, true)) {
LogError("Zone Bootup failed :: Zone::Bootup");
zone = 0;
}
-1
View File
@@ -335,7 +335,6 @@ public:
double GetMaxMovementUpdateRange() const { return max_movement_update_range; }
/**
* Modding hooks
*/
+77
View File
@@ -0,0 +1,77 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "zone_store.h"
ZoneStore::ZoneStore() = default;
ZoneStore::~ZoneStore() = default;
void ZoneStore::LoadZonesStore()
{
zones = ZoneRepository::All();
}
uint32 ZoneStore::GetZoneID(const char *in_zone_name)
{
if (in_zone_name == nullptr) {
return 0;
}
std::string zone_name = in_zone_name;
return GetZoneID(zone_name);
}
uint32 ZoneStore::GetZoneID(std::string zone_name)
{
for (auto &z: zones) {
if (z.short_name == zone_name) {
return z.zoneidnumber;
}
}
return 0;
}
const char *ZoneStore::GetZoneName(uint32 zone_id, bool error_unknown)
{
for (auto &z: zones) {
if (z.zoneidnumber == zone_id) {
return z.short_name.c_str();
}
}
if (error_unknown) {
return "UNKNOWN";
}
return nullptr;
}
std::string ZoneStore::GetZoneName(uint32 zone_id)
{
for (auto &z: zones) {
if (z.zoneidnumber == zone_id) {
return z.short_name;
}
}
return std::string();
}
+59
View File
@@ -0,0 +1,59 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_ZONE_STORE_H
#define EQEMU_ZONE_STORE_H
#include "zonedb.h"
#include "../common/repositories/zone_repository.h"
class ZoneStore {
public:
ZoneStore();
virtual ~ZoneStore();
std::vector<ZoneRepository::Zone> zones;
void LoadZonesStore();
uint32 GetZoneID(const char *in_zone_name);
uint32 GetZoneID(std::string zone_name);
std::string GetZoneName(uint32 zone_id);
const char *GetZoneName(uint32 zone_id, bool error_unknown);
};
extern ZoneStore zone_store;
/**
* Global helpers
*/
inline uint32 ZoneID(const char *in_zone_name) { return zone_store.GetZoneID(in_zone_name); }
inline uint32 ZoneID(std::string zone_name) { return zone_store.GetZoneID(zone_name); }
inline std::string ZoneName(uint32 zone_id) { return zone_store.GetZoneName(zone_id); }
inline const char *ZoneName(uint32 zone_id, bool error_unknown)
{
return zone_store.GetZoneName(
zone_id,
error_unknown
);
}
#endif //EQEMU_ZONE_STORE_H