aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/serverscriptpersistence.cpp
blob: 4f7bba88d40d32b6ceb47daa23e8a9e537e4a7de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "pch.h"
#include "serverscriptpersistence.h"
#include "squirrel.h"
#include "masterserver.h"
#include "serverauthentication.h"

// void function NSEarlyWritePlayerPersistenceForLeave( entity player )
SQInteger SQ_EarlyWritePlayerPersistenceForLeave(void* sqvm)
{
	void* player;
	if (!ServerSq_getentity(sqvm, &player) || !g_ServerAuthenticationManager->m_additionalPlayerData.count(player))
		return 0;

	g_ServerAuthenticationManager->m_additionalPlayerData[player].needPersistenceWriteOnLeave = false;
	g_ServerAuthenticationManager->WritePersistentData(player);
	return 0;
}

// bool function NSIsWritingPlayerPersistence()
SQInteger SQ_IsWritingPlayerPersistence(void* sqvm)
{
	ServerSq_pushbool(sqvm, g_MasterServerManager->m_savingPersistentData);
	return 1;
}

void InitialiseServerScriptPersistence(HMODULE baseAddress)
{
	g_ServerSquirrelManager->AddFuncRegistration("void", "NSEarlyWritePlayerPersistenceForLeave", "entity player", "", SQ_EarlyWritePlayerPersistenceForLeave);
	g_ServerSquirrelManager->AddFuncRegistration("bool", "NSIsWritingPlayerPersistence", "", "", SQ_IsWritingPlayerPersistence);
}