prevent some protocol crashs

This commit is contained in:
Eduardo Bart 2012-04-03 19:24:15 -03:00
parent c33741d324
commit cb890e8cb1
2 changed files with 22 additions and 3 deletions

View File

@ -42,7 +42,6 @@ void Graphics::init()
const char *requiredExtensions[] = { const char *requiredExtensions[] = {
"GL_ARB_vertex_program", "GL_ARB_vertex_program",
"GL_ARB_vertex_shader", "GL_ARB_vertex_shader",
"GL_ARB_fragment_program",
"GL_ARB_fragment_shader", "GL_ARB_fragment_shader",
"GL_ARB_texture_non_power_of_two", "GL_ARB_texture_non_power_of_two",
"GL_ARB_multitexture" "GL_ARB_multitexture"
@ -58,7 +57,10 @@ void Graphics::init()
} }
if(unsupported) if(unsupported)
logFatal("The following OpenGL 2.0 extensions are not supported by your system graphics, please try updating your video drivers or buy a new hardware:\n", ss.str()); logFatal("The following OpenGL 2.0 extensions are not supported by your system graphics, please try updating your video drivers or buy a new hardware:\n",
ss.str(),
"Graphics card: ", glGetString(GL_RENDERER),
"\nOpenGL driver: ", glGetString(GL_VERSION));
m_useFBO = m_useFBO && GLEW_ARB_framebuffer_object; m_useFBO = m_useFBO && GLEW_ARB_framebuffer_object;
m_generateHardwareMipmaps = m_generateHardwareMipmaps && m_useFBO; // glGenerateMipmap is supported when FBO is m_generateHardwareMipmaps = m_generateHardwareMipmaps && m_useFBO; // glGenerateMipmap is supported when FBO is

View File

@ -278,6 +278,7 @@ void ProtocolGame::parseMessage(InputMessage& msg)
void ProtocolGame::parseInitGame(InputMessage& msg) void ProtocolGame::parseInitGame(InputMessage& msg)
{ {
logTraceDebug();
uint playerId = msg.getU32(); uint playerId = msg.getU32();
int serverBeat = msg.getU16(); int serverBeat = msg.getU16();
msg.getU8(); // can report bugs, ignored msg.getU8(); // can report bugs, ignored
@ -291,6 +292,7 @@ void ProtocolGame::parseInitGame(InputMessage& msg)
void ProtocolGame::parseGMActions(InputMessage& msg) void ProtocolGame::parseGMActions(InputMessage& msg)
{ {
// not used // not used
logTraceDebug();
for(int i = 0; i < Proto::NumViolationReasons; ++i) for(int i = 0; i < Proto::NumViolationReasons; ++i)
msg.getU8(); msg.getU8();
} }
@ -747,18 +749,28 @@ void ProtocolGame::parsePlayerStats(InputMessage& msg)
double soul = msg.getU8(); double soul = msg.getU8();
double stamina = msg.getU16(); double stamina = msg.getU16();
if(!m_localPlayer) {
logTraceError("there is no local player");
return;
}
m_localPlayer->setHealth(health, maxHealth); m_localPlayer->setHealth(health, maxHealth);
m_localPlayer->setFreeCapacity(freeCapacity); m_localPlayer->setFreeCapacity(freeCapacity);
m_localPlayer->setExperience(experience); m_localPlayer->setExperience(experience);
m_localPlayer->setLevel(level, levelPercent); m_localPlayer->setLevel(level, levelPercent);
m_localPlayer->setMana(mana, maxMana); m_localPlayer->setMana(mana, maxMana);
m_localPlayer->setMagicLevel(magicLevel, magicLevelPercent); m_localPlayer->setMagicLevel(magicLevel, magicLevelPercent);
m_localPlayer->setSoul(soul);
m_localPlayer->setStamina(stamina); m_localPlayer->setStamina(stamina);
m_localPlayer->setSoul(soul);
} }
void ProtocolGame::parsePlayerSkills(InputMessage& msg) void ProtocolGame::parsePlayerSkills(InputMessage& msg)
{ {
if(!m_localPlayer) {
logTraceError("there is no local player");
return;
}
for(int skill = 0; skill < Otc::LastSkill; skill++) { for(int skill = 0; skill < Otc::LastSkill; skill++) {
int level = msg.getU8(); int level = msg.getU8();
int levelPercent = msg.getU8(); int levelPercent = msg.getU8();
@ -769,6 +781,11 @@ void ProtocolGame::parsePlayerSkills(InputMessage& msg)
void ProtocolGame::parsePlayerState(InputMessage& msg) void ProtocolGame::parsePlayerState(InputMessage& msg)
{ {
if(!m_localPlayer) {
logTraceError("there is no local player");
return;
}
int states = msg.getU16(); int states = msg.getU16();
m_localPlayer->setStates((Otc::PlayerStates)states); m_localPlayer->setStates((Otc::PlayerStates)states);
} }