From 7ce577cc3048b91a10b5f26809f3b5bd8feeffd1 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sat, 8 Jul 2023 14:42:19 -0300 Subject: Fix race condition --- npc/functions/hub.txt | 19 +++---------------- npc/functions/vault.txt | 21 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/npc/functions/hub.txt b/npc/functions/hub.txt index ae347bd..a10b9a9 100644 --- a/npc/functions/hub.txt +++ b/npc/functions/hub.txt @@ -143,22 +143,9 @@ function script HUB_Logout { // Register logout time if (!.@dead) { CHAREG_CLEANUP=gettimetick(2); - // Send updates to Vault API - if (getvaultid()) { - .@api$=json_encode("UID", ##VAULT, - "GID", getcharid(3), - "VAR1N", "CRQUEST", - "VAR1V", ##01_CRQUEST, - //"VAR2N", "CRWORLD", - //"VAR2V", ##01_CRWORLD, - "VEXP", ##VAULT_EXP, - "GOTO", ##VAULT_GOTO, - "MLTO", ##VAULT_MLTO); - ##VAULT_EXP=0; - ##VAULT_GOTO=0; - ##VAULT_MLTO=0; - api_send(API_FLUSHVAULT, .@api$); - } + export_vault(); + ##VAULT_GOTO=0; + ##VAULT_MLTO=0; } return; diff --git a/npc/functions/vault.txt b/npc/functions/vault.txt index a2adf7c..89a6161 100644 --- a/npc/functions/vault.txt +++ b/npc/functions/vault.txt @@ -15,12 +15,30 @@ function script getvaultexp { RB_DEBUGMES | RB_IRCBROADCAST | RB_GLOBALANNOUNCE | RB_ISFATAL); if (getvaultid()) { ##VAULT_EXP+=.@exp; - consoleinfo("Granting %d Soul Exp to %d under the Moubootaur's authority.", + consoleinfo("Granting %d Soul Exp to %d under the Crossroads' authority.", .@exp, ##VAULT); } return; } +function script export_vault { + // Send updates to Vault API + if (getvaultid()) { + .@api$=json_encode("UID", ##VAULT, + "GID", getcharid(3), + "VAR1N", "CRQUEST", + "VAR1V", ##01_CRQUEST, + //"VAR2N", "CRWORLD", + //"VAR2V", ##01_CRWORLD, + "VEXP", ##VAULT_EXP, + "GOTO", ##VAULT_GOTO, + "MLTO", ##VAULT_MLTO); + ##VAULT_EXP=0; + api_send(API_FLUSHVAULT, .@api$); + } + return; +} + // MirrorLakeSendTo(World, Lake) function script MirrorLakeSendTo { .@w=getarg(0); @@ -29,6 +47,7 @@ function script MirrorLakeSendTo { ##VAULT_MLTO=.@t; closeclientdialog; dispbottom l("Darkness fills your vision..."); + export_vault(); sleep2(1000); kick(getcharid(3), 7); // 7 is not a valid kick reason //atcommand("@kick "+strcharinfo(0)); -- cgit v1.2.3-60-g2f50