forked from 0ad/0ad
olsner
7bcc12373b
- Changed player colour JS interface: setColour(...) instead of a colour property - Introduced a network log and replaced most network LOG() calls with NET_LOG() - Moved to a slot-based system for Pre-Game and extended a lot of the JS APIs to networking stuff - A bit of cleanup in the low-level network code (Unix parts) - Clients now keep track of all other connected clients on the server (And exposes this info to JS) - Split out GameAttributes to its own file - Removed unused class AttributeMap - Changed CJSObject to use T* pointers in JS_SetPrivate (needed to make ToScript work with multiple inheritance) This was SVN commit r1929.
68 lines
1.5 KiB
C++
Executable File
68 lines
1.5 KiB
C++
Executable File
#ifndef _Player_H
|
|
#define _Player_H
|
|
|
|
#include "CStr.h"
|
|
#include "scripting/SynchedJSObject.h"
|
|
#include "scripting/ScriptableObject.h"
|
|
#include "scripting/ScriptCustomTypes.h"
|
|
#include "EntityHandles.h"
|
|
|
|
class CNetMessage;
|
|
|
|
typedef SColour SPlayerColour;
|
|
|
|
class CPlayer : public CSynchedJSObject<CPlayer>
|
|
{
|
|
public:
|
|
typedef void (UpdateCallback)(CStrW name, CStrW value, CPlayer *player, void *userdata);
|
|
|
|
private:
|
|
CStrW m_Name;
|
|
PS_uint m_PlayerID;
|
|
SPlayerColour m_Colour;
|
|
|
|
UpdateCallback *m_UpdateCB;
|
|
void *m_UpdateCBData;
|
|
|
|
virtual void Update(CStrW name, ISynchedJSProperty *prop);
|
|
|
|
public:
|
|
CPlayer( uint playerID );
|
|
|
|
bool ValidateCommand(CNetMessage *pMsg);
|
|
|
|
inline PS_uint GetPlayerID() const
|
|
{ return m_PlayerID; }
|
|
inline void SetPlayerID(PS_uint id)
|
|
{ m_PlayerID=id; }
|
|
|
|
inline const CStrW &GetName() const
|
|
{ return m_Name; }
|
|
inline void SetName(const CStrW &name)
|
|
{ m_Name = name; }
|
|
|
|
inline const SPlayerColour &GetColour() const
|
|
{ return m_Colour; }
|
|
inline void SetColour(const SPlayerColour &colour)
|
|
{ m_Colour = colour; }
|
|
|
|
inline void SetUpdateCallback(UpdateCallback *cb, void *userdata)
|
|
{
|
|
m_UpdateCB=cb;
|
|
m_UpdateCBData=userdata;
|
|
}
|
|
void SetValue(CStrW name, CStrW value);
|
|
|
|
// Caller frees...
|
|
std::vector<HEntity>* GetControlledEntities();
|
|
|
|
// JS Interface Functions
|
|
jsval JSI_ToString( JSContext* context, uintN argc, jsval* argv );
|
|
jsval JSI_GetControlledEntities();
|
|
jsval JSI_SetColour(JSContext *context, uintN argc, jsval *argv);
|
|
|
|
static void ScriptingInit();
|
|
};
|
|
|
|
#endif
|