OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
sciReport.h
1
3#ifndef __SCIREPORT_H__
4#define __SCIREPORT_H__
5
6
9#include "sci.h"
10#include "../hashtable.h"
11
12
13#ifdef __cplusplus
14extern "C" {
15#endif // __cplusplus
16
17
20// Constants
21#define SC_REPORT_PROTOCOL 2
22
23// NOTE: broke up entity index in two - for later versions we will want to send the 2 byte
24// team index followed by the 4 byte team ID later in the stream
25
26 // Protocol length settings
27#define SC_REPORT_ROSTERDATA_LENGTH 20 // V1.0 - 16 byte connection id + 4 byte team index
28#define SC_REPORT_PLAYERINDEX_LENGTH 2 // V1.0 - 2 bytes for a player index
29#define SC_REPORT_TEAMINDEX_LENGTH 4 // V1.0 - 4 bytes for a team index
30#define SC_REPORT_AUTHDATA_LENGTH 16 // V1.0 - length of auth data per player
31#define SC_REPORT_ENTITYRESULT_LENGTH 4 // V1.0 - 4 byte enum value
32
33
34#define SC_REPORT_ENTITY_NONE 0
35#define SC_REPORT_ENTITY_PLAYER 1
36#define SC_REPORT_ENTITY_TEAM 2
37
38// (must match server)
39#define SC_REPORT_FLAG_AUTHORITATIVE (1<<0)
40#define SC_REPORT_FLAG_NON_RELATIVE_RESULT (1<<1)
41#define SC_REPORT_FLAG_MATCHLESS_SESSION (1<<2)
42//#define SC_REPORT_FLAG_DEDICATED_HOST (1<<3)
43
44typedef enum
45{
46 SCIReportState_NONE,
47 SCIReportState_ROSTER,
48 //SCIReportState_AUTHDATA,
49 //SCIReportState_RESTULTS,
50 SCIReportState_GLOBALDATA,
51 SCIReportState_PLAYERDATA,
52 SCIReportState_TEAMDATA
53} SCIReportState;
54
55typedef enum
56{
57 SCIKeyType_INT32,
58 SCIKeyType_INT16,
59 SCIKeyType_BYTE,
60 SCIKeyType_STRING,
61 SCIKeyType_FLOAT,
62 SCIKeyType_INT64
63} SCIKeyType;
64
67// Structs
68typedef struct SCIReportHeader
69{
70 gsi_u32 mProtocolVersion; // To support future changes
71 gsi_u32 mDeveloperVersion;
72 gsi_u8 mChecksum[GS_CRYPT_MD5_HASHSIZE]; // Hash(session, player, team data)
73 gsi_u32 mGameStatus;
74 gsi_u32 mFlags; // Flags for authoritative, final, etc.
75 gsi_u16 mPlayerCount; // Players in session
76 gsi_u16 mTeamCount; // Teams in session
77 gsi_u16 mGameKeyCount;
78 gsi_u16 mPlayerKeyCount;
79 gsi_u16 mTeamKeyCount;
80 gsi_u16 mReserved; // pad, for 32-bit alignment
81 gsi_u32 mRosterSectionLength; //
82 gsi_u32 mAuthSectionLength; //
83 gsi_u32 mResultsSectionLength; //
84 gsi_u32 mGameSectionLength; //
85 gsi_u32 mPlayerSectionLength; //
86 gsi_u32 mTeamSectionLength; //
88
89
92typedef struct SCIReportBuffer
93{
94 gsi_bool mIsStatic;
95
96 gsi_u32 mLen;
97 gsi_u32 mCapacity;
98 gsi_u32 mPos;
99
100 char * mData;
101
103
104typedef struct SCIReport
105{
106 SCIReportState mReportState;
107
108 gsi_i32 mCurEntityStartPos; // where this entity's data begins
109 gsi_u16 mCurEntityKeyCount; // how many keys we've added for this entity
110
111 //gsi_u32 mNumPlayersReported; // to check against expected count - not used
112 gsi_u32 mNumResultsReported; // to check against expected count
113
114 gsi_u32 mNumTeamsReported; // keeps track of the number of team IDs that have been reported
115 gsi_u32 mTeamIds[SC_MAX_NUM_TEAMS]; // internal list of team IDs
116
117 SCIReportBuffer mBuffer;
118} SCIReport;
119
120
123SCResult sciCreateReport(gsi_u8 theSessionGuid[16],
124 gsi_u32 theHeaderVersion,
125 gsi_u32 thePlayerCount,
126 gsi_u32 theTeamCount,
127 SCIReport ** theReportOut);
128
129SCResult sciDestroyReport(SCIReport *theReport);
130
133// ReportData functions
134SCResult SC_CALL sciReportSetPlayerConnectionId(SCIReport * theReport, gsi_u32 thePlayerIndex, const gsi_u8 theConnectionId[SC_CONNECTION_GUID_SIZE]);
135SCResult SC_CALL sciReportSetPlayerTeamIndex (SCIReport * theReport, gsi_u32 thePlayerIndex, gsi_u32 theTeamIndex);
136SCResult SC_CALL sciReportSetPlayerGameResult (SCIReport * theReport, gsi_u32 thePlayerIndex, SCGameResult theGameResult);
137SCResult SC_CALL sciReportSetPlayerAuthInfo (SCIReport * theReport, gsi_u32 thePlayerIndex, const GSLoginCertificate * theCertificate, const gsi_u8 theAuthHash[16]);
138SCResult SC_CALL sciReportSetTeamGameResult (SCIReport * theReport, gsi_u32 theTeamIndex , SCGameResult theGameResult);
139SCResult SC_CALL sciReportSetAsMatchless (SCIReport * theReport);
140
141// Key/Value data
142SCResult SC_CALL sciReportBeginGlobalData(SCIReport * theReport);
143SCResult SC_CALL sciReportBeginPlayerData(SCIReport * theReport);
144SCResult SC_CALL sciReportBeginTeamData (SCIReport * theReport);
145
146SCResult SC_CALL sciReportAddIntValue(SCIReport * theReport,
147 gsi_u16 theKeyId,
148 gsi_i32 theValue);
149SCResult SC_CALL sciReportAddInt64Value(SCIReport * theReport,
150 gsi_u16 theKeyId,
151 gsi_i64 theValue);
152SCResult SC_CALL sciReportAddShortValue(SCIReport * theReport,
153 gsi_u16 theKeyId,
154 gsi_i16 theValue);
155SCResult SC_CALL sciReportAddByteValue(SCIReport * theReport,
156 gsi_u16 theKeyId,
157 gsi_i8 theValue);
158SCResult SC_CALL sciReportAddFloatValue(SCIReport * theReport,
159 gsi_u16 theKeyId,
160 float theValue);
161SCResult SC_CALL sciReportAddStringValue(SCIReport * theReport,
162 gsi_u16 theKeyId,
163 const gsi_char * theValue);
164
165SCResult SC_CALL sciReportBeginNewTeam(SCIReport * theReport);
166SCResult SC_CALL sciReportBeginNewPlayer(SCIReport * theReport);
167SCResult SC_CALL sciReportEndEntity(SCIReport * theReport);
168// Call when finished writing
169SCResult SC_CALL sciReportEnd(SCIReport * theReport, gsi_bool isAuth, SCGameStatus theStatus);
170
171
172
173
174
175
178#ifdef __cplusplus
179} // extern "C"
180#endif // __cplusplus
181
182
185#endif // __SCREPORT_H__
Definition AuthService.h:87
Definition sciReport.h:93
Definition sciReport.h:69
Definition sciReport.h:105