Revision: 1457
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1457&view=rev
Author: rorthomas
Date: 2010-07-17 21:59:30 +0000 (Sat, 17 Jul 2010)
Log Message:
-----------
client refactored regarding new rornet variables
Modified Paths:
--------------
trunk/source/main/Beam.cpp
trunk/source/main/BeamData.h
trunk/source/main/Character.cpp
trunk/source/main/ChatSystem.cpp
trunk/source/main/network.cpp
trunk/source/main/network.h
Modified: trunk/source/main/Beam.cpp
===================================================================
--- trunk/source/main/Beam.cpp 2010-07-17 12:55:58 UTC (rev 1456)
+++ trunk/source/main/Beam.cpp 2010-07-17 21:59:30 UTC (rev 1457)
@@ -10964,14 +10964,14 @@
{
client_t *c = net->getClientInfo(sourceid);
if(!c) return;
- networkUsername = String(c->user_name);
- networkAuthlevel = c->user_authlevel;
+ networkUsername = String(c->user.clientname);
+ networkAuthlevel = c->user.authstatus;
} else
{
- client_info_on_join *info = net->getLocalUserData();
+ user_info_t *info = net->getLocalUserData();
if(!info) return;
- if(!strlen(info->nickname)) return;
- networkUsername = String(info->nickname);
+ if(!strlen(info->clientname)) return;
+ networkUsername = String(info->clientname);
networkAuthlevel = info->authstatus;
}
Modified: trunk/source/main/BeamData.h
===================================================================
--- trunk/source/main/BeamData.h 2010-07-17 12:55:58 UTC (rev 1456)
+++ trunk/source/main/BeamData.h 2010-07-17 21:59:30 UTC (rev 1457)
@@ -52,6 +52,7 @@
// The RoR required includes
#include "RoRPrerequisites.h"
+#include "rornet.h"
// some tool to define the bitmasks. We use this, as it it far better readable
(prevents errors)
#define BITMASK(x) (1 << (x-1))
@@ -767,21 +768,12 @@
struct client
{
+ user_info_t user; //!< user struct
bool used; //!< if this slot is used already
+
int trucknum; //!< the truck's number of the
truck bound to this slot
- int slotnum; //!< server slot number
bool loaded; //!< if the truck bound to this
slot is loaded
bool invisible; //!< if the truck is invisible for
the user (since he dont have the required resource)
-
- char client_version[10]; //!< clients version, i.e.
RoR-0.36.1
- char protocol_version[10]; //!< protocol version, i.e.
RoRNet-3.0
- char truck_name[255]; //!< the truck filename, i.e.
agoras.truck
- unsigned int truck_size; //!< the size truck buffer needed
- char user_language[10]; //!< the users language
- char user_name[20]; //!< the users nickname
- unsigned int user_id; //!< the users id, set by the server
- unsigned int user_authlevel; //!< the users authorization level.
- int colournum; //!< the users authorization colour
};
struct authorinfo
Modified: trunk/source/main/Character.cpp
===================================================================
--- trunk/source/main/Character.cpp 2010-07-17 12:55:58 UTC (rev 1456)
+++ trunk/source/main/Character.cpp 2010-07-17 21:59:30 UTC (rev 1457)
@@ -147,19 +147,17 @@
{
client_t *info = net->getClientInfo(this->source);
if(!info) return;
- if(!strlen(info->user_name)) return;
- // update colour
- this->colourNumber = info->colournum;
- networkUsername = info->user_name;
- networkAuthLevel = info->user_authlevel;
+ if(!strlen(info->user.clientname)) return;
+ this->colourNumber = info->user.colournum;
+ networkUsername = info->user.clientname;
+ networkAuthLevel = info->user.authstatus;
} else
{
- client_info_on_join *info = net->getLocalUserData();
+ user_info_t *info = net->getLocalUserData();
if(!info) return;
- if(!strlen(info->nickname)) return;
- // update colour
+ if(!strlen(info->clientname)) return;
this->colourNumber = info->colournum;
- networkUsername = String(info->nickname);
+ networkUsername = String(info->clientname);
networkAuthLevel = info->authstatus;
}
Modified: trunk/source/main/ChatSystem.cpp
===================================================================
--- trunk/source/main/ChatSystem.cpp 2010-07-17 12:55:58 UTC (rev 1456)
+++ trunk/source/main/ChatSystem.cpp 2010-07-17 21:59:30 UTC (rev 1457)
@@ -94,12 +94,12 @@
#ifdef USE_SOCKETW
if(te && tec)
{
- client_info_on_join *c = net->getLocalUserData();
+ user_info_t *c = net->getLocalUserData();
if(c)
{
try
{
- UTFString username = tryConvertUTF(c->nickname);
+ UTFString username =
tryConvertUTF(c->clientname);
te->setCaption(username);
String matName =
PlayerColours::getSingleton().getColourMaterial(c->colournum);
@@ -128,7 +128,7 @@
try
{
- UTFString username = tryConvertUTF(c->user_name);
+ UTFString username = tryConvertUTF(c->user.clientname);
String plstr = StringConverter::toString(num) + ": " +
ColoredTextAreaOverlayElement::StripColors(username);
@@ -138,11 +138,11 @@
tec =
(TextAreaOverlayElement*)OverlayManager::getSingleton().getOverlayElement(colname);
if(!te || !tec) break;
te->setCaption(plstr);
- String matName =
PlayerColours::getSingleton().getColourMaterial(c->colournum);
+ String matName =
PlayerColours::getSingleton().getColourMaterial(c->user.colournum);
tec->setMaterialName(matName);
- if(c->user_authlevel & AUTH_ADMIN)
+ if(c->user.authstatus & AUTH_ADMIN)
te->setColour(ColourValue(1,0,0));
- else if(c->user_authlevel & AUTH_RANKED)
+ else if(c->user.authstatus & AUTH_RANKED)
te->setColour(ColourValue(0,1,0));
else
te->setColour(ColourValue::Black);
@@ -184,14 +184,14 @@
client_t *c = net->getClientInfo(source);
if(c)
{
- username = tryConvertUTF(c->user_name);
+ username = tryConvertUTF(c->user.clientname);
int nickColour = 8;
- if(c->user_authlevel & AUTH_NONE) nickColour = 8; //
grey
- if(c->user_authlevel & AUTH_BOT ) nickColour = 4; //
blue
- if(c->user_authlevel & AUTH_RANKED) nickColour = 2; //
green
- if(c->user_authlevel & AUTH_MOD) nickColour = 1; //
red
- if(c->user_authlevel & AUTH_ADMIN) nickColour = 1; //
red
+ if(c->user.authstatus & AUTH_NONE) nickColour = 8; //
grey
+ if(c->user.authstatus & AUTH_BOT ) nickColour = 4; //
blue
+ if(c->user.authstatus & AUTH_RANKED) nickColour = 2; //
green
+ if(c->user.authstatus & AUTH_MOD) nickColour = 1; //
red
+ if(c->user.authstatus & AUTH_ADMIN) nickColour = 1; //
red
mNickColour = String("^") +
StringConverter::toString(nickColour);
username = mNickColour +
ColoredTextAreaOverlayElement::StripColors(username);
Modified: trunk/source/main/network.cpp
===================================================================
--- trunk/source/main/network.cpp 2010-07-17 12:55:58 UTC (rev 1456)
+++ trunk/source/main/network.cpp 2010-07-17 21:59:30 UTC (rev 1457)
@@ -91,7 +91,7 @@
ChatSystemFactory::getSingleton().setNetwork(this);
//
- memset(&userdata, 0, sizeof(client_info_on_join));
+ memset(&userdata, 0, sizeof(user_info_t));
shutdown=false;
#ifdef USE_OPENAL
ssm=SoundScriptManager::getSingleton();
@@ -237,13 +237,13 @@
}
// construct user credentials
- user_credentials_t c;
- memset(&c, 0, sizeof(user_credentials_t));
+ user_info_t c;
+ memset(&c, 0, sizeof(user_info_t));
strncpy(c.username, nickname.c_str(), 20);
- strncpy(c.password, sha1pwresult, 40);
- strncpy(c.uniqueid, usertokensha1result, 40);
+ strncpy(c.serverpassword, sha1pwresult, 40);
+ strncpy(c.usertoken, usertokensha1result, 40);
- if (sendmessage(&socket, MSG2_USER_CREDENTIALS, 0,
sizeof(user_credentials_t), (char*)&c))
+ if (sendmessage(&socket, MSG2_USER_CREDENTIALS, 0, sizeof(user_info_t),
(char*)&c))
{
//this is an error!
netFatalError("Establishing network session: error sending
hello", false);
@@ -505,7 +505,7 @@
stream_register_t *reg = (stream_register_t *)buffer;
client_t *client = getClientInfo(header.source);
int playerColour = 0;
- if(client) playerColour = client->colournum;
+ if(client) playerColour = client->user.colournum;
String typeStr = "unkown";
switch(reg->type)
@@ -557,7 +557,7 @@
// debug stuff
/*
LogManager::getSingleton().logMessage(" >
received user info:" + StringConverter::toString(header.source) + " (we are " +
StringConverter::toString(myuid) + ")");
- client_info_on_join *cinfo =
(client_info_on_join*) buffer;
+ user_info_t *cinfo = (user_info_t*) buffer;
LogManager::getSingleton().logMessage(" *
version : " + StringConverter::toString(cinfo->version));
LogManager::getSingleton().logMessage(" *
nickname: " + String(cinfo->nickname));
LogManager::getSingleton().logMessage(" * auth
: " + StringConverter::toString(cinfo->authstatus));
@@ -567,24 +567,22 @@
if(header.source == (int)myuid)
{
// we got data about ourself!
- memcpy(&userdata, buffer,
sizeof(client_info_on_join));
+ memcpy(&userdata, buffer, sizeof(user_info_t));
CharacterFactory::getSingleton().localUserAttributesChanged(myuid);
// update our nickname
- nickname = String(userdata.nickname);
+ nickname = String(userdata.clientname);
// update auth status
myauthlevel = userdata.authstatus;
} else
{
- client_info_on_join *cinfo =
(client_info_on_join*) buffer;
+ user_info_t *cinfo = (user_info_t*) buffer;
// data about someone else, try to update the
array
bool found = false; // whether to add a new
client
client_t *client = getClientInfo(header.source);
if(client)
{
- client->user_authlevel =
cinfo->authstatus;
- client->slotnum = cinfo->slotnum;
- client->colournum= cinfo->colournum;
- strncpy(client->user_name,
cinfo->nickname, 20);
+ memcpy(&client->user, cinfo,
sizeof(user_info_t));
+
// inform the streamfactories of a
attribute change
CharacterFactory::getSingleton().netUserAttributesChanged(header.source, -1);
BeamFactory::getSingleton().netUserAttributesChanged(header.source, -1);
@@ -598,13 +596,11 @@
if (clients[i].used)
continue;
clients[i].used = true;
- clients[i].user_id =
header.source;
- clients[i].user_authlevel =
cinfo->authstatus;
- clients[i].slotnum =
cinfo->slotnum;
- clients[i].colournum =
cinfo->colournum;
+ memcpy(&clients[i].user, cinfo,
sizeof(user_info_t));
+
+ // inform the streamfactories
of a attribute change
CharacterFactory::getSingleton().netUserAttributesChanged(header.source, -1);
BeamFactory::getSingleton().netUserAttributesChanged(header.source, -1);
-
strncpy(clients[i].user_name,cinfo->nickname, 20);
break;
}
pthread_mutex_unlock(&clients_mutex);
@@ -624,7 +620,7 @@
client_t *c = 0;
for (int i=0; i<MAX_PEERS; i++)
{
- if (clients[i].user_id == uid)
+ if (clients[i].user.uniqueid == uid)
c = &clients[i];
}
// pthread_mutex_unlock(&clients_mutex);
Modified: trunk/source/main/network.h
===================================================================
--- trunk/source/main/network.h 2010-07-17 12:55:58 UTC (rev 1456)
+++ trunk/source/main/network.h 2010-07-17 21:59:30 UTC (rev 1457)
@@ -66,7 +66,7 @@
Ogre::String nickname;
int rconauthed;
bool shutdown;
- client_info_on_join userdata;
+ user_info_t userdata;
SoundScriptManager* ssm;
Ogre::String getUserChatName(client_t *c);
void calcSpeed();
@@ -100,7 +100,7 @@
int getSpeedUp();
int getSpeedDown();
- client_info_on_join *getLocalUserData() { return &userdata; };
+ user_info_t *getLocalUserData() { return &userdata; };
static unsigned int getUID() { return myuid; };
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel