mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 19:48:26 +00:00
[Spawn] (imported from takp) Added min_time and max_time to spawnentry. This will prevent a NPC from… (#3685)
* Added mintime and maxtime to spawnentry. This will prevent a NPC from spawning outside of the times specified. NPCs spawned in this way will then behave like normal NPCs. They will not despawn on their own, unlike spawn_events/spawn_conditions. NPCs using this that are alone in their spawngroup will attempt to spawn after their respawn timer has expired if the time of day is outside their range. Otherwise, another NPC in the spawngroup will be chosen to spawn. The normal rules (chance, spawn_limit) still apply to these NPCs, this is just another rule added to the system. mintime and maxtime both represent the in-game EQ Hour. Valid values are 1-24. If either or both of the values are 0, then the NPC will not have any time restriction. Added a new rule World:BootHour. This allows server admins to specify the EQ hour the server will boot to. Valid options are 1-24. Setting this rule to 0 (default) disables it and world will use whatever time is specified in the DB. * generated base_spawnentry_repository.h from script * removed the rule insert from database_update_manifest.cpp. * Add logging, initializers, minor cleanup * Remove if/else branch * Update eqtime.cpp * Initializers, logging --------- Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
+29
-21
@@ -2097,37 +2097,45 @@ void Database::ClearInvSnapshots(bool from_now) {
|
||||
|
||||
struct TimeOfDay_Struct Database::LoadTime(time_t &realtime)
|
||||
{
|
||||
|
||||
TimeOfDay_Struct eqTime;
|
||||
std::string query = StringFormat("SELECT minute,hour,day,month,year,realtime FROM eqtime limit 1");
|
||||
TimeOfDay_Struct t{};
|
||||
std::string query = StringFormat("SELECT minute,hour,day,month,year,realtime FROM eqtime limit 1");
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success() || results.RowCount() == 0){
|
||||
if (!results.Success() || results.RowCount() == 0) {
|
||||
LogInfo("Loading EQ time of day failed. Using defaults");
|
||||
eqTime.minute = 0;
|
||||
eqTime.hour = 9;
|
||||
eqTime.day = 1;
|
||||
eqTime.month = 1;
|
||||
eqTime.year = 3100;
|
||||
t.minute = 0;
|
||||
t.hour = 9;
|
||||
t.day = 1;
|
||||
t.month = 1;
|
||||
t.year = 3100;
|
||||
realtime = time(nullptr);
|
||||
}
|
||||
else{
|
||||
auto row = results.begin();
|
||||
|
||||
eqTime.minute = Strings::ToUnsignedInt(row[0]);
|
||||
eqTime.hour = Strings::ToUnsignedInt(row[1]);
|
||||
eqTime.day = Strings::ToUnsignedInt(row[2]);
|
||||
eqTime.month = Strings::ToUnsignedInt(row[3]);
|
||||
eqTime.year = Strings::ToUnsignedInt(row[4]);
|
||||
realtime = Strings::ToBigInt(row[5]);
|
||||
return t;
|
||||
}
|
||||
|
||||
return eqTime;
|
||||
auto row = results.begin();
|
||||
|
||||
uint8 hour = Strings::ToUnsignedInt(row[1]);
|
||||
time_t realtime_ = Strings::ToBigInt(row[5]);
|
||||
if (RuleI(World, BootHour) > 0 && RuleI(World, BootHour) <= 24) {
|
||||
hour = RuleI(World, BootHour);
|
||||
realtime_ = time(nullptr);
|
||||
}
|
||||
|
||||
t.minute = Strings::ToUnsignedInt(row[0]);
|
||||
t.hour = hour;
|
||||
t.day = Strings::ToUnsignedInt(row[2]);
|
||||
t.month = Strings::ToUnsignedInt(row[3]);
|
||||
t.year = Strings::ToUnsignedInt(row[4]);
|
||||
realtime = realtime_;
|
||||
|
||||
LogEqTime("Setting hour to [{}]", hour);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
bool Database::SaveTime(int8 minute, int8 hour, int8 day, int8 month, int16 year)
|
||||
{
|
||||
std::string query = StringFormat("UPDATE eqtime set minute = %d, hour = %d, day = %d, month = %d, year = %d, realtime = %d limit 1", minute, hour, day, month, year, time(0));
|
||||
std::string query = StringFormat("UPDATE eqtime set minute = %d, hour = %d, day = %d, month = %d, year = %d, realtime = %d limit 1", minute, hour, day, month, year, time(nullptr));
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
return results.Success();
|
||||
|
||||
Reference in New Issue
Block a user