Share skills and attributes correctly upon logging in, and fix grammar

coverity_scan^2
David Cernat 8 years ago
parent dd6ebdeb4f
commit a2dbeb6c95

@ -296,8 +296,9 @@ void Networking::NewPlayer(RakNet::RakNetGUID guid)
controller->GetPacket(ID_USER_MYID)->Send(Players::GetPlayer(guid), false); controller->GetPacket(ID_USER_MYID)->Send(Players::GetPlayer(guid), false);
controller->GetPacket(ID_GAME_BASE_INFO)->RequestData(guid); controller->GetPacket(ID_GAME_BASE_INFO)->RequestData(guid);
//controller->GetPacket(ID_GAME_UPDATE_SKILLS)->RequestData(guid);
controller->GetPacket(ID_GAME_UPDATE_BASESTATS)->RequestData(guid); controller->GetPacket(ID_GAME_UPDATE_BASESTATS)->RequestData(guid);
controller->GetPacket(ID_GAME_ATTRIBUTE)->RequestData(guid);
controller->GetPacket(ID_GAME_SKILL)->RequestData(guid);
controller->GetPacket(ID_GAME_UPDATE_POS)->RequestData(guid); controller->GetPacket(ID_GAME_UPDATE_POS)->RequestData(guid);
controller->GetPacket(ID_GAME_CELL)->RequestData(guid); controller->GetPacket(ID_GAME_CELL)->RequestData(guid);
controller->GetPacket(ID_GAME_UPDATE_EQUIPED)->RequestData(guid); controller->GetPacket(ID_GAME_UPDATE_EQUIPED)->RequestData(guid);
@ -307,8 +308,9 @@ void Networking::NewPlayer(RakNet::RakNetGUID guid)
if (pl->first == guid) continue; if (pl->first == guid) continue;
controller->GetPacket(ID_GAME_BASE_INFO)->Send(pl->second, guid); controller->GetPacket(ID_GAME_BASE_INFO)->Send(pl->second, guid);
//controller->GetPacket(ID_GAME_UPDATE_SKILLS)->Send(pl->second, guid);
controller->GetPacket(ID_GAME_UPDATE_BASESTATS)->Send(pl->second, guid); controller->GetPacket(ID_GAME_UPDATE_BASESTATS)->Send(pl->second, guid);
controller->GetPacket(ID_GAME_ATTRIBUTE)->Send(pl->second, guid);
controller->GetPacket(ID_GAME_SKILL)->Send(pl->second, guid);
controller->GetPacket(ID_GAME_UPDATE_POS)->Send(pl->second, guid); controller->GetPacket(ID_GAME_UPDATE_POS)->Send(pl->second, guid);
controller->GetPacket(ID_GAME_CELL)->Send(pl->second, guid); controller->GetPacket(ID_GAME_CELL)->Send(pl->second, guid);
controller->GetPacket(ID_GAME_UPDATE_EQUIPED)->Send(pl->second, guid); controller->GetPacket(ID_GAME_UPDATE_EQUIPED)->Send(pl->second, guid);
@ -316,6 +318,8 @@ void Networking::NewPlayer(RakNet::RakNetGUID guid)
} }
void Networking::DisconnectPlayer(RakNet::RakNetGUID guid) void Networking::DisconnectPlayer(RakNet::RakNetGUID guid)
{ {
Script::Call<Script::CallbackIdentity("OnPlayerDisconnect")>(Players::GetPlayer(guid)->GetID()); Script::Call<Script::CallbackIdentity("OnPlayerDisconnect")>(Players::GetPlayer(guid)->GetID());
@ -362,7 +366,7 @@ int Networking::MainLoop()
printf("Another client has disconnected.\n"); printf("Another client has disconnected.\n");
break; break;
case ID_REMOTE_CONNECTION_LOST: case ID_REMOTE_CONNECTION_LOST:
printf("Another client has lost the connection.\n"); printf("Another client has lost connection.\n");
break; break;
case ID_REMOTE_NEW_INCOMING_CONNECTION: case ID_REMOTE_NEW_INCOMING_CONNECTION:
printf("Another client has connected.\n"); printf("Another client has connected.\n");
@ -383,7 +387,7 @@ int Networking::MainLoop()
DisconnectPlayer(packet->guid); DisconnectPlayer(packet->guid);
break; break;
case ID_CONNECTION_LOST: case ID_CONNECTION_LOST:
printf("A client lost the connection.\n"); printf("A client has lost connection.\n");
DisconnectPlayer(packet->guid); DisconnectPlayer(packet->guid);
break; break;
default: default:

@ -52,7 +52,7 @@ void Networking::Update()
printf("Another client has disconnected.\n"); printf("Another client has disconnected.\n");
break; break;
case ID_REMOTE_CONNECTION_LOST: case ID_REMOTE_CONNECTION_LOST:
printf("Another client has lost the connection.\n"); printf("Another client has lost connection.\n");
break; break;
case ID_REMOTE_NEW_INCOMING_CONNECTION: case ID_REMOTE_NEW_INCOMING_CONNECTION:
printf("Another client has connected.\n"); printf("Another client has connected.\n");
@ -119,7 +119,7 @@ void Networking::Connect(const std::string &ip, unsigned short port)
{ {
errmsg = "Connection failed.\n" errmsg = "Connection failed.\n"
"The client or server is outdated.\n" "The client or server is outdated.\n"
"Ask your server administrator for resolve this problem."; "Ask your server administrator to resolve this problem.";
queue = false; queue = false;
break; break;
} }
@ -261,17 +261,24 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
} }
case ID_GAME_UPDATE_SKILLS: case ID_GAME_UPDATE_SKILLS:
{ {
printf("Received ID_GAME_UPDATE_SKILLS from server\n");
if (id == myid) if (id == myid)
{ {
printf("- Packet was about my id\n");
getLocalPlayer()->updateAttributesAndSkills(true); getLocalPlayer()->updateAttributesAndSkills(true);
myPacket->Send(getLocalPlayer(), serverAddr); myPacket->Send(getLocalPlayer(), serverAddr);
} }
else if (pl != 0) else if (pl != 0)
{ {
printf("- Packet was about %s\n", pl->Npc()->mName.c_str());
myPacket->Packet(&bsIn, pl, false); myPacket->Packet(&bsIn, pl, false);
MWMechanics::SkillValue skillValue; MWMechanics::SkillValue skillValue;
MWMechanics::AttributeValue attributeValue; MWMechanics::AttributeValue attributeValue;
for (int i = 0; i < PacketAttributesAndStats::StatsCount; ++i) for (int i = 0; i < PacketAttributesAndStats::StatsCount; ++i)
{ {
skillValue.readState(pl->NpcStats()->mSkills[i]); skillValue.readState(pl->NpcStats()->mSkills[i]);
@ -381,7 +388,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
} }
else if (pl != 0) else if (pl != 0)
{ {
printf("attempt to kill %s\n", pl->Npc()->mName.c_str()); printf("Attempt to kill %s\n", pl->Npc()->mName.c_str());
MWMechanics::DynamicStat<float> health; MWMechanics::DynamicStat<float> health;
pl->CreatureStats()->mDead = true; pl->CreatureStats()->mDead = true;
health.readState(pl->CreatureStats()->mDynamic[0]); health.readState(pl->CreatureStats()->mDynamic[0]);

@ -1,5 +1,5 @@
[General] [General]
#0 - Verbose (spam), 1 - Info, 2 - Warnings, 3 - Errors, 4 - Only fatal errors # 0 - Verbose (spam), 1 - Info, 2 - Warnings, 3 - Errors, 4 - Only fatal errors
loglevel = 0 loglevel = 0
#master = master.tes3mp.com:8088 #master = master.tes3mp.com:8088
server = mp.tes3mp.com server = mp.tes3mp.com
@ -7,12 +7,12 @@ port = 25565
#name = Player #name = Player
[Chat] [Chat]
#use https://wiki.libsdl.org/SDL_Keycode for rebind keys # Use https://wiki.libsdl.org/SDL_Keycode for rebinding keys
keySay = Y #key for switch chat mode enabled/hidden/disabled keySay = Y # For chatting
keyChatMode = F2 keyChatMode = F2 # For enabling or disabling the chat window
x = 0 x = 0
y = 0 y = 0
w = 390 w = 390
h = 250 h = 250
delay = 5.0 #how long the message will be displayed in hidden mode delay = 5.0 # How long the message will be displayed in hidden mode

Loading…
Cancel
Save