Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

Commit

Permalink
PR: Added the C++ backbone for updating Digging Zones
Browse files Browse the repository at this point in the history
  • Loading branch information
m241dan committed Dec 23, 2019
1 parent 7afec44 commit 0fddecd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/map/lua/luautils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4428,6 +4428,23 @@ namespace luautils
return canDig;
}

int32 UpdateDigZones()
{
lua_prepscript("scripts/globals/chocobo_digging.lua");

if (prepFile(File, "updateDigZones"))
return false;

if (lua_pcall(LuaHandle, 0, 0, 0))
{
ShowError("luautils::UpdateDigZones: %s\n", lua_tostring(LuaHandle, -1));
lua_pop(LuaHandle, 1);
return false;
}

return 0;
}

/************************************************************************
* Loads a Lua function with a fallback hierarchy *
* *
Expand Down
1 change: 1 addition & 0 deletions src/map/lua/luautils.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ namespace luautils
int32 OnPlayerLevelDown(CCharEntity* PChar);

bool OnChocoboDig(CCharEntity* PChar, bool pre); // chocobo digging, pre = check
int32 UpdateDigZones(); // updating chocobo digging zones with items
bool LoadEventScript(CCharEntity* PChar, const char* functionName); // Utility method: checks for and loads a lua function for events

uint16 GetDespoilDebuff(uint16 itemId); // Ask the database for an effectId based on Item despoiled (returns 0 if not in db)
Expand Down
7 changes: 7 additions & 0 deletions src/map/time_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,16 @@ int32 time_server(time_point tick,CTaskMgr::CTask* PTask)

CVanaTime::getInstance()->lastVHourlyUpdate = tick;
}
}

// every irl minute
if (tick > (CVanaTime::getInstance()->lastMinute + 60s))
{
luautils::UpdateDigZones();
CVanaTime::getInstance()->lastMinute = tick;
}


//Midnight
if (CVanaTime::getInstance()->getSysHour() == 0 && CVanaTime::getInstance()->getSysMinute() == 0)
{
Expand Down
1 change: 1 addition & 0 deletions src/map/vana_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class CVanaTime
time_point lastVDailyUpdate;
time_point lastConquestTally;
time_point lastMidnight;
time_point lastMinute;

private:

Expand Down

0 comments on commit 0fddecd

Please sign in to comment.