mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +00:00
Merge branch 'master' of https://github.com/EQEmu/Server
This commit is contained in:
@@ -1703,7 +1703,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
|
||||
/* Time of Day packet */
|
||||
outapp = new EQApplicationPacket(OP_TimeOfDay, sizeof(TimeOfDay_Struct));
|
||||
TimeOfDay_Struct* tod = (TimeOfDay_Struct*)outapp->pBuffer;
|
||||
zone->zone_time.getEQTimeOfDay(time(0), tod);
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(time(0), tod);
|
||||
outapp->priority = 6;
|
||||
FastQueuePacket(&outapp);
|
||||
|
||||
|
||||
+3
-3
@@ -1369,7 +1369,7 @@ void command_date(Client *c, const Seperator *sep)
|
||||
else {
|
||||
int h=0, m=0;
|
||||
TimeOfDay_Struct eqTime;
|
||||
zone->zone_time.getEQTimeOfDay( time(0), &eqTime);
|
||||
zone->zone_time.GetCurrentEQTimeOfDay( time(0), &eqTime);
|
||||
if(!sep->IsNumber(4))
|
||||
h=eqTime.hour;
|
||||
else
|
||||
@@ -1402,7 +1402,7 @@ void command_timezone(Client *c, const Seperator *sep)
|
||||
// Update all clients with new TZ.
|
||||
EQApplicationPacket* outapp = new EQApplicationPacket(OP_TimeOfDay, sizeof(TimeOfDay_Struct));
|
||||
TimeOfDay_Struct* tod = (TimeOfDay_Struct*)outapp->pBuffer;
|
||||
zone->zone_time.getEQTimeOfDay(time(0), tod);
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(time(0), tod);
|
||||
entity_list.QueueClients(c, outapp);
|
||||
safe_delete(outapp);
|
||||
}
|
||||
@@ -4393,7 +4393,7 @@ void command_time(Client *c, const Seperator *sep)
|
||||
else {
|
||||
c->Message(13, "To set the Time: #time HH [MM]");
|
||||
TimeOfDay_Struct eqTime;
|
||||
zone->zone_time.getEQTimeOfDay( time(0), &eqTime);
|
||||
zone->zone_time.GetCurrentEQTimeOfDay( time(0), &eqTime);
|
||||
sprintf(timeMessage,"%02d:%s%d %s (Timezone: %ih %im)",
|
||||
((eqTime.hour - 1) % 12) == 0 ? 12 : ((eqTime.hour - 1) % 12),
|
||||
(eqTime.minute < 10) ? "0" : "",
|
||||
|
||||
+8
-1
@@ -425,8 +425,15 @@ int32 Mob::GetActSpellDuration(uint16 spell_id, int32 duration)
|
||||
// a level 53 bard reported getting 2 tics
|
||||
if (IsShortDurationBuff(spell_id) && IsBardSong(spell_id) && spells[spell_id].mana == 0 && GetClass() == BARD && GetLevel() > 60)
|
||||
tic_inc++;
|
||||
float focused = ((duration * increase) / 100.0f) + tic_inc;
|
||||
int ifocused = static_cast<int>(focused);
|
||||
|
||||
return (((duration * increase) / 100) + tic_inc);
|
||||
// 7.6 is rounded to 7, 8.6 is rounded to 9
|
||||
// 6 is 6, etc
|
||||
if (FCMP(focused, ifocused) || ifocused % 2) // equal or odd
|
||||
return ifocused;
|
||||
else // even and not equal round to odd
|
||||
return ifocused + 1;
|
||||
}
|
||||
|
||||
int32 Client::GetActSpellCasttime(uint16 spell_id, int32 casttime)
|
||||
|
||||
+1
-1
@@ -1072,7 +1072,7 @@ void PerlembParser::ExportZoneVariables(std::string &package_name) {
|
||||
ExportVar(package_name.c_str(), "instanceid", zone->GetInstanceID());
|
||||
ExportVar(package_name.c_str(), "instanceversion", zone->GetInstanceVersion());
|
||||
TimeOfDay_Struct eqTime;
|
||||
zone->zone_time.getEQTimeOfDay( time(0), &eqTime);
|
||||
zone->zone_time.GetCurrentEQTimeOfDay( time(0), &eqTime);
|
||||
ExportVar(package_name.c_str(), "zonehour", eqTime.hour - 1);
|
||||
ExportVar(package_name.c_str(), "zonemin", eqTime.minute);
|
||||
ExportVar(package_name.c_str(), "zonetime", (eqTime.hour - 1) * 100 + eqTime.minute);
|
||||
|
||||
+18
-5
@@ -1182,13 +1182,26 @@ XS(XS__settime);
|
||||
XS(XS__settime)
|
||||
{
|
||||
dXSARGS;
|
||||
if (items != 2)
|
||||
Perl_croak(aTHX_ "Usage: settime(new_hour, new_min)");
|
||||
if (items < 2)
|
||||
Perl_croak(aTHX_ "Usage: settime(new_hour, new_min, [update_world = true])");
|
||||
|
||||
int new_hour = (int)SvIV(ST(0));
|
||||
int new_min = (int)SvIV(ST(1));
|
||||
if (items == 2){
|
||||
int new_hour = (int)SvIV(ST(0));
|
||||
int new_min = (int)SvIV(ST(1));
|
||||
quest_manager.settime(new_hour, new_min, true);
|
||||
}
|
||||
else if (items == 3){
|
||||
int new_hour = (int)SvIV(ST(0));
|
||||
int new_min = (int)SvIV(ST(1));
|
||||
|
||||
quest_manager.settime(new_hour, new_min);
|
||||
int update_world = (int)SvIV(ST(2));
|
||||
if (update_world == 1){
|
||||
quest_manager.settime(new_hour, new_min, true);
|
||||
}
|
||||
else{
|
||||
quest_manager.settime(new_hour, new_min, false);
|
||||
}
|
||||
}
|
||||
|
||||
XSRETURN_EMPTY;
|
||||
}
|
||||
|
||||
@@ -386,7 +386,11 @@ void lua_create_guild(const char *name, const char *leader) {
|
||||
}
|
||||
|
||||
void lua_set_time(int hour, int min) {
|
||||
quest_manager.settime(hour, min);
|
||||
quest_manager.settime(hour, min, true);
|
||||
}
|
||||
|
||||
void lua_set_time(int hour, int min, bool update_world) {
|
||||
quest_manager.settime(hour, min, update_world);
|
||||
}
|
||||
|
||||
void lua_signal(int npc_id, int signal_id) {
|
||||
@@ -979,7 +983,7 @@ int lua_get_zone_weather() {
|
||||
|
||||
luabind::adl::object lua_get_zone_time(lua_State *L) {
|
||||
TimeOfDay_Struct eqTime;
|
||||
zone->zone_time.getEQTimeOfDay(time(0), &eqTime);
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(time(0), &eqTime);
|
||||
|
||||
luabind::adl::object ret = luabind::newtable(L);
|
||||
ret["zone_hour"] = eqTime.hour - 1;
|
||||
@@ -1467,7 +1471,8 @@ luabind::scope lua_register_general() {
|
||||
luabind::def("set_sky", &lua_set_sky),
|
||||
luabind::def("set_guild", &lua_set_guild),
|
||||
luabind::def("create_guild", &lua_create_guild),
|
||||
luabind::def("set_time", &lua_set_time),
|
||||
luabind::def("set_time", (void(*)(int, int))&lua_set_time),
|
||||
luabind::def("set_time", (void(*)(int, int, bool))&lua_set_time),
|
||||
luabind::def("signal", (void(*)(int,int))&lua_signal),
|
||||
luabind::def("signal", (void(*)(int,int,int))&lua_signal),
|
||||
luabind::def("set_global", &lua_set_global),
|
||||
|
||||
+1
-1
@@ -823,7 +823,7 @@ XS(XS_NPC_RemoveFromHateList)
|
||||
if(ent == nullptr)
|
||||
Perl_croak(aTHX_ "ent is nullptr, avoiding crash.");
|
||||
|
||||
THIS->CastToMob()->RemoveFromHateList(ent);
|
||||
THIS->RemoveFromHateList(ent);
|
||||
|
||||
}
|
||||
XSRETURN_EMPTY;
|
||||
|
||||
+3
-2
@@ -1292,9 +1292,10 @@ void QuestManager::CreateGuild(const char *guild_name, const char *leader) {
|
||||
}
|
||||
}
|
||||
|
||||
void QuestManager::settime(uint8 new_hour, uint8 new_min) {
|
||||
void QuestManager::settime(uint8 new_hour, uint8 new_min, bool update_world /*= true*/)
|
||||
{
|
||||
if (zone)
|
||||
zone->SetTime(new_hour + 1, new_min);
|
||||
zone->SetTime(new_hour + 1, new_min, update_world);
|
||||
}
|
||||
|
||||
void QuestManager::itemlink(int item_id) {
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ public:
|
||||
void setsky(uint8 new_sky);
|
||||
void setguild(uint32 new_guild_id, uint8 new_rank);
|
||||
void CreateGuild(const char *guild_name, const char *leader);
|
||||
void settime(uint8 new_hour, uint8 new_min);
|
||||
void settime(uint8 new_hour, uint8 new_min, bool update_world = true);
|
||||
void itemlink(int item_id);
|
||||
void signal(int npc_id, int wait_ms = 0);
|
||||
void signalwith(int npc_id, int signal_id, int wait_ms = 0);
|
||||
|
||||
+5
-5
@@ -624,7 +624,7 @@ void SpawnConditionManager::Process() {
|
||||
|
||||
//get our current time
|
||||
TimeOfDay_Struct tod;
|
||||
zone->zone_time.getEQTimeOfDay(&tod);
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(&tod);
|
||||
|
||||
//see if time is past our nearest event.
|
||||
if(EQTime::IsTimeBefore(&next_event, &tod))
|
||||
@@ -673,7 +673,7 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) {
|
||||
}
|
||||
|
||||
TimeOfDay_Struct tod;
|
||||
zone->zone_time.getEQTimeOfDay(&tod);
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(&tod);
|
||||
if(event.strict && (event.next.hour != tod.hour || event.next.day != tod.day || event.next.month != tod.month || event.next.year != tod.year))
|
||||
{
|
||||
Log.Out(Logs::Detail, Logs::Spawns, "Event %d: Unable to execute. Condition is strict, and event time has already passed.", event.id);
|
||||
@@ -871,7 +871,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
|
||||
//better solution, and I just dont care thats much.
|
||||
//get our current time
|
||||
TimeOfDay_Struct tod;
|
||||
zone->zone_time.getEQTimeOfDay(&tod);
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(&tod);
|
||||
|
||||
for(auto cur = spawn_events.begin(); cur != spawn_events.end(); ++cur) {
|
||||
SpawnEvent &cevent = *cur;
|
||||
@@ -1096,7 +1096,7 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri
|
||||
if(reset_base) {
|
||||
Log.Out(Logs::Detail, Logs::Spawns, "Spawn event %d located in this zone. State set. Trigger time reset (period %d).", event_id, cevent.period);
|
||||
//start with the time now
|
||||
zone->zone_time.getEQTimeOfDay(&cevent.next);
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(&cevent.next);
|
||||
//advance the next time by our period
|
||||
EQTime::AddMinutes(cevent.period, &cevent.next);
|
||||
} else {
|
||||
@@ -1141,7 +1141,7 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri
|
||||
if(reset_base) {
|
||||
Log.Out(Logs::Detail, Logs::Spawns, "Spawn event %d is in zone %s. State set. Trigger time reset (period %d). Notifying world.", event_id, zone_short_name.c_str(), e.period);
|
||||
//start with the time now
|
||||
zone->zone_time.getEQTimeOfDay(&e.next);
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(&e.next);
|
||||
//advance the next time by our period
|
||||
EQTime::AddMinutes(e.period, &e.next);
|
||||
} else {
|
||||
|
||||
+26
-22
@@ -742,32 +742,36 @@ void WorldServer::Process() {
|
||||
break;
|
||||
}
|
||||
case ServerOP_SyncWorldTime: {
|
||||
if(zone!=0) {
|
||||
if (zone != 0 && !zone->is_zone_time_localized) {
|
||||
Log.Out(Logs::Moderate, Logs::Zone_Server, "%s Received Message SyncWorldTime", __FUNCTION__);
|
||||
eqTimeOfDay* newtime = (eqTimeOfDay*) pack->pBuffer;
|
||||
zone->zone_time.setEQTimeOfDay(newtime->start_eqtime, newtime->start_realtime);
|
||||
|
||||
eqTimeOfDay* newtime = (eqTimeOfDay*)pack->pBuffer;
|
||||
zone->zone_time.SetCurrentEQTimeOfDay(newtime->start_eqtime, newtime->start_realtime);
|
||||
EQApplicationPacket* outapp = new EQApplicationPacket(OP_TimeOfDay, sizeof(TimeOfDay_Struct));
|
||||
TimeOfDay_Struct* tod = (TimeOfDay_Struct*)outapp->pBuffer;
|
||||
zone->zone_time.getEQTimeOfDay(time(0), tod);
|
||||
TimeOfDay_Struct* time_of_day = (TimeOfDay_Struct*)outapp->pBuffer;
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(time(0), time_of_day);
|
||||
entity_list.QueueClients(0, outapp, false);
|
||||
safe_delete(outapp);
|
||||
//TEST
|
||||
char timeMessage[255];
|
||||
time_t timeCurrent = time(nullptr);
|
||||
TimeOfDay_Struct eqTime;
|
||||
zone->zone_time.getEQTimeOfDay( timeCurrent, &eqTime);
|
||||
//if ( eqTime.hour >= 0 && eqTime.minute >= 0 )
|
||||
//{
|
||||
sprintf(timeMessage,"EQTime [%02d:%s%d %s]",
|
||||
((eqTime.hour - 1) % 12) == 0 ? 12 : ((eqTime.hour - 1) % 12),
|
||||
(eqTime.minute < 10) ? "0" : "",
|
||||
eqTime.minute,
|
||||
(eqTime.hour >= 13) ? "pm" : "am"
|
||||
);
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Time Broadcast Packet: %s", timeMessage);
|
||||
zone->GotCurTime(true);
|
||||
//}
|
||||
//Test
|
||||
|
||||
/* Buffer garbage to generate debug message */
|
||||
char time_message[255];
|
||||
time_t current_time = time(nullptr);
|
||||
TimeOfDay_Struct eq_time;
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(current_time, &eq_time);
|
||||
|
||||
sprintf(time_message, "EQTime [%02d:%s%d %s]",
|
||||
((eq_time.hour - 1) % 12) == 0 ? 12 : ((eq_time.hour - 1) % 12),
|
||||
(eq_time.minute < 10) ? "0" : "",
|
||||
eq_time.minute,
|
||||
(eq_time.hour >= 13) ? "pm" : "am"
|
||||
);
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Time Broadcast Packet: %s", time_message);
|
||||
zone->SetZoneHasCurrentTime(true);
|
||||
|
||||
}
|
||||
if (zone->is_zone_time_localized){
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Received request to sync time from world, but our time is localized currently");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+38
-11
@@ -697,7 +697,7 @@ void Zone::Shutdown(bool quite)
|
||||
|
||||
Log.Out(Logs::General, Logs::Status, "Zone Shutdown: %s (%i)", zone->GetShortName(), zone->GetZoneID());
|
||||
petition_list.ClearPetitions();
|
||||
zone->GotCurTime(false);
|
||||
zone->SetZoneHasCurrentTime(false);
|
||||
if (!quite)
|
||||
Log.Out(Logs::General, Logs::Normal, "Zone shutdown: going to sleep");
|
||||
ZoneLoaded = false;
|
||||
@@ -760,6 +760,8 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name)
|
||||
qGlobals = nullptr;
|
||||
default_ruleset = 0;
|
||||
|
||||
is_zone_time_localized = false;
|
||||
|
||||
loglevelvar = 0;
|
||||
merchantvar = 0;
|
||||
tradevar = 0;
|
||||
@@ -805,7 +807,7 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name)
|
||||
totalBS = 0;
|
||||
aas = nullptr;
|
||||
totalAAs = 0;
|
||||
gottime = false;
|
||||
zone_has_current_time = false;
|
||||
|
||||
Instance_Shutdown_Timer = nullptr;
|
||||
bool is_perma = false;
|
||||
@@ -1484,7 +1486,7 @@ void Zone::Repop(uint32 delay) {
|
||||
|
||||
void Zone::GetTimeSync()
|
||||
{
|
||||
if (worldserver.Connected() && !gottime) {
|
||||
if (worldserver.Connected() && !zone_has_current_time) {
|
||||
ServerPacket* pack = new ServerPacket(ServerOP_GetWorldTime, 0);
|
||||
worldserver.SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
@@ -1508,17 +1510,42 @@ void Zone::SetDate(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute
|
||||
}
|
||||
}
|
||||
|
||||
void Zone::SetTime(uint8 hour, uint8 minute)
|
||||
void Zone::SetTime(uint8 hour, uint8 minute, bool update_world /*= true*/)
|
||||
{
|
||||
if (worldserver.Connected()) {
|
||||
ServerPacket* pack = new ServerPacket(ServerOP_SetWorldTime, sizeof(eqTimeOfDay));
|
||||
eqTimeOfDay* eqtod = (eqTimeOfDay*)pack->pBuffer;
|
||||
zone_time.getEQTimeOfDay(time(0), &eqtod->start_eqtime);
|
||||
eqtod->start_eqtime.minute=minute;
|
||||
eqtod->start_eqtime.hour=hour;
|
||||
eqtod->start_realtime=time(0);
|
||||
printf("Setting master time on world server to: %d:%d (%d)\n", hour, minute, (int)eqtod->start_realtime);
|
||||
worldserver.SendPacket(pack);
|
||||
eqTimeOfDay* eq_time_of_day = (eqTimeOfDay*)pack->pBuffer;
|
||||
|
||||
zone_time.GetCurrentEQTimeOfDay(time(0), &eq_time_of_day->start_eqtime);
|
||||
|
||||
eq_time_of_day->start_eqtime.minute = minute;
|
||||
eq_time_of_day->start_eqtime.hour = hour;
|
||||
eq_time_of_day->start_realtime = time(0);
|
||||
|
||||
/* By Default we update worlds time, but we can optionally no update world which updates the rest of the zone servers */
|
||||
if (update_world){
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Setting master time on world server to: %d:%d (%d)\n", hour, minute, (int)eq_time_of_day->start_realtime);
|
||||
worldserver.SendPacket(pack);
|
||||
|
||||
/* Set Time Localization Flag */
|
||||
zone->is_zone_time_localized = false;
|
||||
}
|
||||
/* When we don't update world, we are localizing ourselves, we become disjointed from normal syncs and set time locally */
|
||||
else{
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Setting zone localized time...");
|
||||
|
||||
zone->zone_time.SetCurrentEQTimeOfDay(eq_time_of_day->start_eqtime, eq_time_of_day->start_realtime);
|
||||
EQApplicationPacket* outapp = new EQApplicationPacket(OP_TimeOfDay, sizeof(TimeOfDay_Struct));
|
||||
TimeOfDay_Struct* time_of_day = (TimeOfDay_Struct*)outapp->pBuffer;
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(time(0), time_of_day);
|
||||
entity_list.QueueClients(0, outapp, false);
|
||||
safe_delete(outapp);
|
||||
|
||||
/* Set Time Localization Flag */
|
||||
zone->is_zone_time_localized = true;
|
||||
}
|
||||
|
||||
safe_delete(pack);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-3
@@ -43,6 +43,7 @@ struct ZonePoint
|
||||
int32 target_zone_instance;
|
||||
uint32 client_version_mask;
|
||||
};
|
||||
|
||||
struct ZoneClientAuth_Struct {
|
||||
uint32 ip; // client's IP address
|
||||
uint32 wid; // client's WorldID#
|
||||
@@ -85,6 +86,10 @@ public:
|
||||
|
||||
Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name);
|
||||
~Zone();
|
||||
|
||||
/* When zone has its own version of time */
|
||||
bool is_zone_time_localized;
|
||||
|
||||
bool Init(bool iStaticZone);
|
||||
bool LoadZoneCFG(const char* filename, uint16 instance_id, bool DontLoadDefault = false);
|
||||
bool SaveZoneCFG();
|
||||
@@ -153,7 +158,7 @@ public:
|
||||
inline bool InstantGrids() { return(!initgrids_timer.Enabled()); }
|
||||
void SetStaticZone(bool sz) { staticzone = sz; }
|
||||
inline bool IsStaticZone() { return staticzone; }
|
||||
inline void GotCurTime(bool time) { gottime = time; }
|
||||
inline void SetZoneHasCurrentTime(bool time) { zone_has_current_time = time; }
|
||||
|
||||
void SpawnConditionChanged(const SpawnCondition &c, int16 old_value);
|
||||
|
||||
@@ -206,7 +211,7 @@ public:
|
||||
EQTime zone_time;
|
||||
void GetTimeSync();
|
||||
void SetDate(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute);
|
||||
void SetTime(uint8 hour, uint8 minute);
|
||||
void SetTime(uint8 hour, uint8 minute, bool update_world = true);
|
||||
|
||||
void weatherSend();
|
||||
bool CanBind() const { return(can_bind); }
|
||||
@@ -319,7 +324,7 @@ private:
|
||||
|
||||
|
||||
bool staticzone;
|
||||
bool gottime;
|
||||
bool zone_has_current_time;
|
||||
|
||||
uint32 pQueuedMerchantsWorkID;
|
||||
uint32 pQueuedTempMerchantsWorkID;
|
||||
|
||||
Reference in New Issue
Block a user