Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

Gameplay.GameSpyStatSerializer


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
class GameSpyStatSerializer extends StatSerializer;

var int nextPlayerStatIndex;

function resetNextPlayerStatIndex()
{
	nextPlayerStatIndex = 0;
}

function int getNextPlayerStatIndex()
{
	return nextPlayerStatIndex++;
}

function gsStatLog(coerce String msg)
{
	Log("    GAMESPY STAT: " $ msg);
}

function onMapStart()
{
}

function onClientConnect(TribesReplicationInfo TRI)
{
}

function onClientDisconnect(TribesReplicationInfo TRI)
{
}

function serializeStat(TribesReplicationInfo TRI, StatData sd)
{
	// We only need to do snapshots for GameSpy stat tracking, so we don't need to serialize individual stats
}

private function sendSnapshot(bool finalSnapshot)
{
	local Array<TribesReplicationInfo> statTrackedPlayers;
	local int j;
	local int i;
	local TribesReplicationInfo TRI;
	local GameSpyManager gsm;

	gsm = Level.GetGameSpyManager();

	ForEach DynamicActors(class'TribesReplicationInfo', TRI)
		if (TRI.playerStatIndex == -1 && TRI.Owner != None && gsm.StatsHasPIDAndResponse(PlayerController(TRI.Owner)))
			statTrackedPlayers[statTrackedPlayers.Length] = TRI;

	if (statTrackedPlayers.Length == 0)
		return;

	gsm.StatsNewGameStarted();
	resetNextPlayerStatIndex();

	gsStatLog("Serializing snapshot");

	gsm.SetServerStat("Mapname", Level.Title);

	gsm.SetServerStat("TeamOne", GameInfo(Level.Game).GetTeamFromIndex(0).localizedName);
	gsm.SetServerStat("TeamTwo", GameInfo(Level.Game).GetTeamFromIndex(1).localizedName);

	gsm.SetServerStat("TeamOneScore", String(GameInfo(Level.Game).GetTeamFromIndex(0).score));
	gsm.SetServerStat("TeamTwoScore", String(GameInfo(Level.Game).GetTeamFromIndex(1).score));

	// Log the player specific stats
	for (j = 0; j < statTrackedPlayers.Length; ++j)
	{
		TRI = statTrackedPlayers[j];

		TRI.playerStatIndex = getNextPlayerStatIndex();

		if (TRI.playerStatIndex != -1) // If stats were tracked for this player
		{
			gsStatLog("    Serializing stats for player " $ TRI.PlayerName);

			Level.GetGameSpyManager().StatsNewPlayer(TRI.playerStatIndex, TRI.PlayerName);

			gsm.SetPlayerStat("pid", gsm.StatsGetPID(PlayerController(TRI.Owner)), TRI.playerStatIndex);
			gsm.SetPlayerStat("auth", gsm.StatsGetStatResponse(PlayerController(TRI.Owner)), TRI.playerStatIndex);

			gsm.SetPlayerStat("team", TRI.team.localizedName, TRI.playerStatIndex);

			gsm.SetPlayerStat("OffenseScore", TRI.offenseScore, TRI.playerStatIndex);
			gsm.SetPlayerStat("DefenseScore", TRI.defenseScore, TRI.playerStatIndex);
			gsm.SetPlayerStat("StyleScore", TRI.styleScore, TRI.playerStatIndex);

			for (i = 0; i < TRI.statDataList.Length; ++i)
			{
				gsm.SetPlayerStat(TRI.statDataList[i].statClass.Name, TRI.statDataList[i].amount, TRI.playerStatIndex);
			}
		}
	}

	gsStatLog("Sending snapshot");
	gsm.SendStatSnapshot(finalSnapshot);
}

function serializeSnapshot()
{
}

function onMapEnd()
{
	if (GetUrlOption("GameStats") ~= "true")
		sendSnapshot(true);
}

defaultproperties
{
	bSerializeOnMapEnd = false
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: čt 7.10.2004 10:30:36.000 - Creation time: st 23.5.2018 00:10:43.534 - Created with UnCodeX