Leaderboard Update & Support for Universe Registration

This commit is contained in:
AconiteX
2021-06-01 05:21:14 -04:00
parent 530f543e33
commit 2f09afaa7c
3 changed files with 25 additions and 7 deletions
@@ -26839,4 +26839,20 @@ public class base_class
}
}
/**
* Registers an Object to the Universe by adding it to the
* tracking list of the Universe Process so that the object
* will always be proxied on every Game Server and thereby
* accessible in any context.
*
* Primary implementation is intended for special Master Objects.
* This should not be used on players or regular tangibles.
*
* @param object the object to register
*/
public static void registerObjectToUniverse(obj_id object) {
_registerObjectToUniverse(getLongWithNull(object));
}
private static native void _registerObjectToUniverse(long target);
} // class base_class
@@ -314,7 +314,7 @@ public class leaderboard extends script.base_script {
}
}
setObjVar(player, OBJVAR_PLAYER_TRACKING_CITY_ALREADY, true);
debugMsg("Adding new city to GCW Leaderboard Participant Group: " + cityGetName(guildId) + " (" + cityId + ")");
debugMsg("Adding new city to GCW Leaderboard Participant Group: " + cityGetName(cityId) + " (" + cityId + ")");
}
}
break;
@@ -21,6 +21,7 @@ public class gcw_master_object extends script.base_script {
}
public int OnInitialize(obj_id self) throws InterruptedException {
registerObjectToUniverse(self);
messageTo(self, "handleLeaderboardInitialization", null, 60f, true);
return SCRIPT_CONTINUE;
}
@@ -30,6 +31,11 @@ public class gcw_master_object extends script.base_script {
return SCRIPT_OVERRIDE;
}
public int OnDestroy(obj_id self) throws InterruptedException {
removeObjVar(getPlanetByName("tatooine"), "leaderboard.master_object");
return SCRIPT_CONTINUE;
}
public int OnHearSpeech(obj_id self, obj_id objSpeaker, String strText) throws InterruptedException {
if(!isGod(objSpeaker)) {
return SCRIPT_CONTINUE;
@@ -52,7 +58,7 @@ public class gcw_master_object extends script.base_script {
// First Time Setup
if(!hasObjVar(tatooine, "leaderboard.master_object")) {
setObjVar(getPlanetByName("tatooine"), "leaderboard.master_object", self);
setObjVar(tatooine, "leaderboard.master_object", self);
messageTo(self, "handleLeaderboardFirstTimeSetup", null, 0f, true);
leaderboard.debugMsg("Handling board initialization as first time setup...");
} else {
@@ -115,11 +121,7 @@ public class gcw_master_object extends script.base_script {
leaderboard.debugMsg("Skipping period heartbeat because we're already in the middle of running one or in a reset...");
return SCRIPT_CONTINUE;
}
// don't run if there's no players online
if(getNumPlayers() < 1) {
leaderboard.debugMsg("Skipping period heartbeat because no players are online...");
return SCRIPT_CONTINUE;
}
// don't run in a buffer, grab all participants
if(leaderboard.isWithinPeriodBuffer() || leaderboard.isWithinStartupBuffer()) {
leaderboard.debugMsg("Skipping period heartbeat because we're within a period or startup buffer...");