Added monster message handlers

This commit is contained in:
Kayne Ruse
2015-01-20 05:02:44 +11:00
parent dacb8df674
commit bd878e20ce
6 changed files with 111 additions and 15 deletions
+30
View File
@@ -0,0 +1,30 @@
/* Copyright: (c) Kayne Ruse 2013-2015
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*/
#include "ip_operators.hpp"
bool operator==(IPaddress lhs, IPaddress rhs) {
return lhs.host == rhs.host && lhs.port == rhs.port;
}
bool operator!=(IPaddress lhs, IPaddress rhs) {
return !(lhs == rhs);
}
+31
View File
@@ -0,0 +1,31 @@
/* Copyright: (c) Kayne Ruse 2013-2015
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*/
#ifndef IPOPERATORS_HPP_
#define IPOPERATORS_HPP_
#include "SDL/SDL_net.h"
//these should've come standard
bool operator==(IPaddress lhs, IPaddress rhs);
bool operator!=(IPaddress lhs, IPaddress rhs);
#endif
+7
View File
@@ -99,6 +99,13 @@ protected:
void HandleCharacterMovement(CharacterPacket* const); void HandleCharacterMovement(CharacterPacket* const);
void HandleCharacterAttack(CharacterPacket* const); void HandleCharacterAttack(CharacterPacket* const);
//monster management
void HandleMonsterCreate(MonsterPacket* const);
void HandleMonsterDelete(MonsterPacket* const);
void HandleMonsterQueryExists(MonsterPacket* const);
void HandleMonsterMovement(MonsterPacket* const);
void HandleMonsterAttack(MonsterPacket* const);
//player movement //player movement
void SendLocalCharacterMovement(); void SendLocalCharacterMovement();
std::list<BoundingBox> GenerateCollisionGrid(Entity*, int tileWidth, int tileHeight); std::list<BoundingBox> GenerateCollisionGrid(Entity*, int tileWidth, int tileHeight);
+25 -1
View File
@@ -28,7 +28,7 @@
#include <stdexcept> #include <stdexcept>
//------------------------- //-------------------------
//entity management //character management
//------------------------- //-------------------------
//DOCS: preexisting characters will result in query responses //DOCS: preexisting characters will result in query responses
@@ -147,6 +147,30 @@ void InWorld::HandleCharacterAttack(CharacterPacket* const argPacket) {
//TODO: attack animation //TODO: attack animation
} }
//-------------------------
//monster management
//-------------------------
void InWorld::HandleMonsterCreate(MonsterPacket* const argPacket) {
//TODO
}
void InWorld::HandleMonsterDelete(MonsterPacket* const argPacket) {
//TODO
}
void InWorld::HandleMonsterQueryExists(MonsterPacket* const argPacket) {
//TODO
}
void InWorld::HandleMonsterMovement(MonsterPacket* const argPacket) {
//TODO
}
void InWorld::HandleMonsterAttack(MonsterPacket* const argPacket) {
//TODO
}
//------------------------- //-------------------------
//player movement //player movement
//------------------------- //-------------------------
+18 -2
View File
@@ -22,6 +22,7 @@
#include "in_world.hpp" #include "in_world.hpp"
#include "channels.hpp" #include "channels.hpp"
#include "ip_operators.hpp"
#include "terminal_error.hpp" #include "terminal_error.hpp"
#include <chrono> #include <chrono>
@@ -68,8 +69,6 @@ void InWorld::HandlePacket(SerialPacket* const argPacket) {
case SerialPacketType::QUERY_CHARACTER_EXISTS: case SerialPacketType::QUERY_CHARACTER_EXISTS:
HandleCharacterQueryExists(static_cast<CharacterPacket*>(argPacket)); HandleCharacterQueryExists(static_cast<CharacterPacket*>(argPacket));
break; break;
//character movement
case SerialPacketType::CHARACTER_MOVEMENT: case SerialPacketType::CHARACTER_MOVEMENT:
HandleCharacterMovement(static_cast<CharacterPacket*>(argPacket)); HandleCharacterMovement(static_cast<CharacterPacket*>(argPacket));
break; break;
@@ -77,6 +76,23 @@ void InWorld::HandlePacket(SerialPacket* const argPacket) {
HandleCharacterAttack(static_cast<CharacterPacket*>(argPacket)); HandleCharacterAttack(static_cast<CharacterPacket*>(argPacket));
break; break;
//monster management
case SerialPacketType::MONSTER_CREATE:
HandleMonsterCreate(static_cast<MonsterPacket*>(argPacket));
break;
case SerialPacketType::MONSTER_DELETE:
HandleMonsterDelete(static_cast<MonsterPacket*>(argPacket));
break;
case SerialPacketType::QUERY_MONSTER_EXISTS:
HandleMonsterQueryExists(static_cast<MonsterPacket*>(argPacket));
break;
case SerialPacketType::MONSTER_MOVEMENT:
HandleMonsterMovement(static_cast<MonsterPacket*>(argPacket));
break;
case SerialPacketType::MONSTER_ATTACK:
HandleMonsterAttack(static_cast<MonsterPacket*>(argPacket));
break;
//rejection messages //rejection messages
case SerialPacketType::REGION_REJECTION: case SerialPacketType::REGION_REJECTION:
case SerialPacketType::CHARACTER_REJECTION: case SerialPacketType::CHARACTER_REJECTION:
@@ -31,18 +31,6 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
//-------------------------
//these should've come standard
//-------------------------
bool operator==(IPaddress lhs, IPaddress rhs) {
return lhs.host == rhs.host && lhs.port == rhs.port;
}
bool operator!=(IPaddress lhs, IPaddress rhs) {
return !(lhs == rhs);
}
//------------------------- //-------------------------
//Public access members //Public access members
//------------------------- //-------------------------