OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
peerPlayers.h
1/*
2GameSpy Peer SDK
3Dan "Mr. Pants" Schoenblum
4dan@gamespy.com
5
6Copyright 1999-2007 GameSpy Industries, Inc
7
8devsupport@gamespy.com
9*/
10
11#ifndef _PEERPLAYERS_H_
12#define _PEERPLAYERS_H_
13
14/*************
15** INCLUDES **
16*************/
17#include "peerMain.h"
18
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24
25/************
26** DEFINES **
27************/
28#define PI_PING_HISTORY_LEN 4
29
30/**********
31** TYPES **
32**********/
33typedef struct piPlayer
34{
35 char nick[PI_NICK_MAX_LEN]; // this has to be first
36 PEERBool inRoom[NumRooms]; // true if in the room
37 PEERBool local; // true for the local player
38
39 unsigned int IP; // the IP in network byte order
40 int profileID; // gp profile id
41 PEERBool gotIPAndProfileID; // true if we have the IP and profile ID
42
43 int flags[NumRooms]; // player's room flags
44
45 // Ping stuff
46 unsigned long lastPingSend; // last time a ping was sent
47 unsigned long lastPingRecv; // last time a ping was received
48 unsigned long lastXping; // last time a xping was sent
49 PEERBool waitingForPing; // if true we're waiting for a ping to return
50 int pingsReturned; // number of pings returned
51 int pingsLostConsecutive; // number of pings lost in a row
52 int pingAverage; // the average ping time
53 int pingHistory[PI_PING_HISTORY_LEN]; // history of pings
54 int pingHistoryNum; // the number of pings in the ping history
55 int numPings; // number of pings for this player
56 PEERBool xpingSent; // if true, we already sent a xping with the current average
57 PEERBool inPingRoom; // true if the player is in a room getting pinged
58 PEERBool inXpingRoom; // true if the player is in a room getting xpinged
59 PEERBool mustPing; // if true, ping this player as soon as possible
60 PEERBool pingOnce; // a one-time ping has been triggered with peerPingPlayer
61} piPlayer;
62
63/**************
64** FUNCTIONS **
65**************/
66PEERBool piPlayersInit(PEER peer);
67void piPlayersCleanup(PEER peer);
68piPlayer * piPlayerJoinedRoom(PEER peer, const char * nick, RoomType roomType, int mode);
69void piPlayerLeftRoom(PEER peer, const char * nick, RoomType roomType);
70void piPlayerChangedNick(PEER peer, const char * oldNick, const char * newNick);
71void piClearRoomPlayers(PEER peer, RoomType roomType);
72piPlayer * piGetPlayer(PEER peer, const char * nick);
73typedef void (* piEnumRoomPlayersCallback)(PEER peer, RoomType roomType, piPlayer * player, int index, void * param);
74void piEnumRoomPlayers(PEER peer, RoomType roomType, piEnumRoomPlayersCallback callback, void * param);
75piPlayer * piFindPlayerByIP(PEER peer, unsigned int IP);
76void piSetPlayerIPAndProfileID(PEER peer, const char * nick, unsigned int IP, int profileID);
77int piParseFlags(const char * flags);
78void piSetPlayerRoomFlags(PEER peer, const char * nick, RoomType roomType, const char * flags);
79void piSetPlayerModeFlags(PEER peer, const char * nick, RoomType roomType, int mode);
80PEERBool piIsPlayerVIP(piPlayer * player, RoomType roomType);
81PEERBool piIsPlayerHost(piPlayer * player);
82PEERBool piIsPlayerOp(piPlayer * player);
83piPlayer * piFindPlayerByIndex(PEER peer, RoomType roomType, int index);
84piPlayer * piFindRoomHost(PEER peer, RoomType roomType);
85piPlayer * piFindRoomOp(PEER peer, RoomType roomType);
86int piCountRoomOps(PEER peer, RoomType roomType, const char * exclude);
87
88#ifdef __cplusplus
89}
90#endif
91
92#endif
Definition peerPlayers.h:34