Brought client into line with server
Also added a new config file for developing over multiple machines.
This commit is contained in:
@@ -19,28 +19,28 @@
|
|||||||
* 3. This notice may not be removed or altered from any source
|
* 3. This notice may not be removed or altered from any source
|
||||||
* distribution.
|
* distribution.
|
||||||
*/
|
*/
|
||||||
#include "base_monster.hpp"
|
#include "base_creature.hpp"
|
||||||
|
|
||||||
#include "config_utility.hpp"
|
#include "config_utility.hpp"
|
||||||
|
|
||||||
void BaseMonster::CorrectSprite() {
|
void BaseCreature::CorrectSprite() {
|
||||||
//TODO: (9) BaseMonster::CorrectSprite()
|
//TODO: (9) BaseCreature::CorrectSprite()
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string BaseMonster::SetHandle(std::string s) {
|
std::string BaseCreature::SetHandle(std::string s) {
|
||||||
return handle = s;
|
return handle = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string BaseMonster::GetHandle() const {
|
std::string BaseCreature::GetHandle() const {
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string BaseMonster::SetAvatar(SDL_Renderer* const renderer, std::string s) {
|
std::string BaseCreature::SetAvatar(SDL_Renderer* const renderer, std::string s) {
|
||||||
avatar = s;
|
avatar = s;
|
||||||
sprite.Load(renderer, ConfigUtility::GetSingleton()["dir.sprites"] + avatar, 4, 1);
|
sprite.Load(renderer, ConfigUtility::GetSingleton()["dir.sprites"] + avatar, 4, 1);
|
||||||
return avatar;
|
return avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string BaseMonster::GetAvatar() const {
|
std::string BaseCreature::GetAvatar() const {
|
||||||
return avatar;
|
return avatar;
|
||||||
}
|
}
|
||||||
@@ -23,10 +23,10 @@
|
|||||||
|
|
||||||
#include "entity.hpp"
|
#include "entity.hpp"
|
||||||
|
|
||||||
class BaseMonster: public Entity {
|
class BaseCreature: public Entity {
|
||||||
public:
|
public:
|
||||||
BaseMonster() = default;
|
BaseCreature() = default;
|
||||||
virtual ~BaseMonster() = default;
|
virtual ~BaseCreature() = default;
|
||||||
|
|
||||||
void CorrectSprite();
|
void CorrectSprite();
|
||||||
|
|
||||||
@@ -19,6 +19,6 @@
|
|||||||
* 3. This notice may not be removed or altered from any source
|
* 3. This notice may not be removed or altered from any source
|
||||||
* distribution.
|
* distribution.
|
||||||
*/
|
*/
|
||||||
#include "terminal_error.hpp"
|
#include "fatal_error.hpp"
|
||||||
|
|
||||||
//DOCS: This empty file is used to force an object file
|
//DOCS: This empty file is used to force an object file
|
||||||
@@ -122,7 +122,7 @@ void LobbyMenu::RenderFrame(SDL_Renderer* renderer) {
|
|||||||
|
|
||||||
//draw the server's info
|
//draw the server's info
|
||||||
serverVector[i].nameImage.DrawTo(renderer, boundingBox.x, boundingBox.y + boundingBox.h * i);
|
serverVector[i].nameImage.DrawTo(renderer, boundingBox.x, boundingBox.y + boundingBox.h * i);
|
||||||
serverVector[i].playerCountImage.DrawTo(renderer, boundingBox.x+300, boundingBox.y + boundingBox.h * i);
|
serverVector[i].playerCountImage.DrawTo(renderer, boundingBox.x+276, boundingBox.y + boundingBox.h * i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+67
-119
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "channels.hpp"
|
#include "channels.hpp"
|
||||||
#include "ip_operators.hpp"
|
#include "ip_operators.hpp"
|
||||||
#include "terminal_error.hpp"
|
#include "fatal_error.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
//static functions
|
//static functions
|
||||||
//-------------------------
|
//-------------------------
|
||||||
@@ -103,7 +104,7 @@ World::~World() {
|
|||||||
//unload the local data
|
//unload the local data
|
||||||
TTF_CloseFont(font);
|
TTF_CloseFont(font);
|
||||||
characterMap.clear();
|
characterMap.clear();
|
||||||
monsterMap.clear();
|
creatureMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
@@ -125,7 +126,7 @@ void World::Update() {
|
|||||||
HandlePacket(packetBuffer);
|
HandlePacket(packetBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(terminal_error& e) {
|
catch(fatal_error& e) {
|
||||||
throw(e);
|
throw(e);
|
||||||
}
|
}
|
||||||
catch(std::exception& e) {
|
catch(std::exception& e) {
|
||||||
@@ -142,7 +143,7 @@ void World::Update() {
|
|||||||
for (auto& it : characterMap) {
|
for (auto& it : characterMap) {
|
||||||
it.second.Update();
|
it.second.Update();
|
||||||
}
|
}
|
||||||
for (auto& it : monsterMap) {
|
for (auto& it : creatureMap) {
|
||||||
it.second.Update();
|
it.second.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +151,7 @@ void World::Update() {
|
|||||||
//update the map
|
//update the map
|
||||||
UpdateMap();
|
UpdateMap();
|
||||||
}
|
}
|
||||||
catch(terminal_error& e) {
|
catch(fatal_error& e) {
|
||||||
throw(e);
|
throw(e);
|
||||||
}
|
}
|
||||||
catch(std::exception& e) {
|
catch(std::exception& e) {
|
||||||
@@ -165,8 +166,6 @@ void World::Update() {
|
|||||||
//get the collidable boxes
|
//get the collidable boxes
|
||||||
std::list<BoundingBox> boxList = GenerateCollisionGrid(localCharacter, tileSheet.GetTileW(), tileSheet.GetTileH());
|
std::list<BoundingBox> boxList = GenerateCollisionGrid(localCharacter, tileSheet.GetTileW(), tileSheet.GetTileH());
|
||||||
|
|
||||||
std::cout << "Debug: " << boxList.size() << std::endl;
|
|
||||||
|
|
||||||
//process the collisions
|
//process the collisions
|
||||||
//BUG: Collisions not working
|
//BUG: Collisions not working
|
||||||
if (localCharacter->ProcessCollisionGrid(boxList)) {
|
if (localCharacter->ProcessCollisionGrid(boxList)) {
|
||||||
@@ -199,7 +198,7 @@ void World::RenderFrame(SDL_Renderer* renderer) {
|
|||||||
//BUG: #29 Characters (and other entities) are drawn out of order
|
//BUG: #29 Characters (and other entities) are drawn out of order
|
||||||
it.second.DrawTo(renderer, camera.x, camera.y);
|
it.second.DrawTo(renderer, camera.x, camera.y);
|
||||||
}
|
}
|
||||||
for (auto& it : monsterMap) {
|
for (auto& it : creatureMap) {
|
||||||
it.second.DrawTo(renderer, camera.x, camera.y);
|
it.second.DrawTo(renderer, camera.x, camera.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,55 +380,36 @@ void World::HandlePacket(SerialPacket* const argPacket) {
|
|||||||
case SerialPacketType::CHARACTER_UPDATE:
|
case SerialPacketType::CHARACTER_UPDATE:
|
||||||
hCharacterUpdate(static_cast<CharacterPacket*>(argPacket));
|
hCharacterUpdate(static_cast<CharacterPacket*>(argPacket));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SerialPacketType::CHARACTER_CREATE:
|
case SerialPacketType::CHARACTER_CREATE:
|
||||||
hCharacterCreate(static_cast<CharacterPacket*>(argPacket));
|
hCharacterCreate(static_cast<CharacterPacket*>(argPacket));
|
||||||
break;
|
break;
|
||||||
case SerialPacketType::CHARACTER_DELETE:
|
case SerialPacketType::CHARACTER_UNLOAD:
|
||||||
hCharacterDelete(static_cast<CharacterPacket*>(argPacket));
|
hCharacterUnload(static_cast<CharacterPacket*>(argPacket));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SerialPacketType::QUERY_CHARACTER_EXISTS:
|
case SerialPacketType::QUERY_CHARACTER_EXISTS:
|
||||||
hQueryCharacterExists(static_cast<CharacterPacket*>(argPacket));
|
hQueryCharacterExists(static_cast<CharacterPacket*>(argPacket));
|
||||||
break;
|
break;
|
||||||
case SerialPacketType::QUERY_CHARACTER_STATS:
|
|
||||||
hQueryCharacterStats(static_cast<CharacterPacket*>(argPacket));
|
|
||||||
break;
|
|
||||||
case SerialPacketType::QUERY_CHARACTER_LOCATION:
|
|
||||||
hQueryCharacterLocation(static_cast<CharacterPacket*>(argPacket));
|
|
||||||
break;
|
|
||||||
case SerialPacketType::CHARACTER_MOVEMENT:
|
case SerialPacketType::CHARACTER_MOVEMENT:
|
||||||
hCharacterMovement(static_cast<CharacterPacket*>(argPacket));
|
hCharacterMovement(static_cast<CharacterPacket*>(argPacket));
|
||||||
break;
|
break;
|
||||||
case SerialPacketType::CHARACTER_ATTACK:
|
|
||||||
hCharacterAttack(static_cast<CharacterPacket*>(argPacket));
|
//creature management
|
||||||
|
case SerialPacketType::CREATURE_CREATE:
|
||||||
|
hCreatureCreate(static_cast<CreaturePacket*>(argPacket));
|
||||||
break;
|
break;
|
||||||
case SerialPacketType::CHARACTER_DAMAGE:
|
case SerialPacketType::CREATURE_UNLOAD:
|
||||||
hCharacterDamage(static_cast<CharacterPacket*>(argPacket));
|
hCreatureUnload(static_cast<CreaturePacket*>(argPacket));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//monster management
|
case SerialPacketType::QUERY_CREATURE_EXISTS:
|
||||||
case SerialPacketType::MONSTER_CREATE:
|
hQueryCreatureExists(static_cast<CreaturePacket*>(argPacket));
|
||||||
hMonsterCreate(static_cast<MonsterPacket*>(argPacket));
|
|
||||||
break;
|
break;
|
||||||
case SerialPacketType::MONSTER_DELETE:
|
|
||||||
hMonsterDelete(static_cast<MonsterPacket*>(argPacket));
|
case SerialPacketType::CREATURE_MOVEMENT:
|
||||||
break;
|
hCreatureMovement(static_cast<CreaturePacket*>(argPacket));
|
||||||
case SerialPacketType::QUERY_MONSTER_EXISTS:
|
|
||||||
hQueryMonsterExists(static_cast<MonsterPacket*>(argPacket));
|
|
||||||
break;
|
|
||||||
case SerialPacketType::QUERY_MONSTER_STATS:
|
|
||||||
hQueryMonsterStats(static_cast<MonsterPacket*>(argPacket));
|
|
||||||
break;
|
|
||||||
case SerialPacketType::QUERY_MONSTER_LOCATION:
|
|
||||||
hQueryMonsterLocation(static_cast<MonsterPacket*>(argPacket));
|
|
||||||
break;
|
|
||||||
case SerialPacketType::MONSTER_MOVEMENT:
|
|
||||||
hMonsterMovement(static_cast<MonsterPacket*>(argPacket));
|
|
||||||
break;
|
|
||||||
case SerialPacketType::MONSTER_ATTACK:
|
|
||||||
hMonsterAttack(static_cast<MonsterPacket*>(argPacket));
|
|
||||||
break;
|
|
||||||
case SerialPacketType::MONSTER_DAMAGE:
|
|
||||||
hMonsterDamage(static_cast<MonsterPacket*>(argPacket));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//chat
|
//chat
|
||||||
@@ -447,7 +427,7 @@ void World::HandlePacket(SerialPacket* const argPacket) {
|
|||||||
case SerialPacketType::REGION_REJECTION:
|
case SerialPacketType::REGION_REJECTION:
|
||||||
case SerialPacketType::CHARACTER_REJECTION:
|
case SerialPacketType::CHARACTER_REJECTION:
|
||||||
case SerialPacketType::QUERY_REJECTION:
|
case SerialPacketType::QUERY_REJECTION:
|
||||||
throw(terminal_error(static_cast<TextPacket*>(argPacket)->text));
|
throw(fatal_error(static_cast<TextPacket*>(argPacket)->text));
|
||||||
break;
|
break;
|
||||||
case SerialPacketType::SHUTDOWN_REJECTION:
|
case SerialPacketType::SHUTDOWN_REJECTION:
|
||||||
throw(std::runtime_error(static_cast<TextPacket*>(argPacket)->text));
|
throw(std::runtime_error(static_cast<TextPacket*>(argPacket)->text));
|
||||||
@@ -709,7 +689,7 @@ void World::hCharacterCreate(CharacterPacket* const argPacket) {
|
|||||||
newPacket.type = SerialPacketType::QUERY_CHARACTER_EXISTS;
|
newPacket.type = SerialPacketType::QUERY_CHARACTER_EXISTS;
|
||||||
newPacket.roomIndex = roomIndex;
|
newPacket.roomIndex = roomIndex;
|
||||||
network.SendTo(Channels::SERVER, &newPacket);
|
network.SendTo(Channels::SERVER, &newPacket);
|
||||||
newPacket.type = SerialPacketType::QUERY_MONSTER_EXISTS;
|
newPacket.type = SerialPacketType::QUERY_CREATURE_EXISTS;
|
||||||
network.SendTo(Channels::SERVER, &newPacket);
|
network.SendTo(Channels::SERVER, &newPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -717,7 +697,7 @@ void World::hCharacterCreate(CharacterPacket* const argPacket) {
|
|||||||
std::cout << "Character Create, total: " << characterMap.size() << std::endl;
|
std::cout << "Character Create, total: " << characterMap.size() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::hCharacterDelete(CharacterPacket* const argPacket) {
|
void World::hCharacterUnload(CharacterPacket* const argPacket) {
|
||||||
//ignore if this character doesn't exist
|
//ignore if this character doesn't exist
|
||||||
std::map<int, BaseCharacter>::iterator characterIt = characterMap.find(argPacket->characterIndex);
|
std::map<int, BaseCharacter>::iterator characterIt = characterMap.find(argPacket->characterIndex);
|
||||||
if (characterIt == characterMap.end()) {
|
if (characterIt == characterMap.end()) {
|
||||||
@@ -736,7 +716,7 @@ void World::hCharacterDelete(CharacterPacket* const argPacket) {
|
|||||||
roomIndex = -1;
|
roomIndex = -1;
|
||||||
regionPager.UnloadAll();
|
regionPager.UnloadAll();
|
||||||
characterMap.clear();
|
characterMap.clear();
|
||||||
monsterMap.clear();
|
creatureMap.clear();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//remove this character
|
//remove this character
|
||||||
@@ -744,7 +724,7 @@ void World::hCharacterDelete(CharacterPacket* const argPacket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//debug
|
//debug
|
||||||
std::cout << "Character Delete, total: " << characterMap.size() << std::endl;
|
std::cout << "Character Unload, total: " << characterMap.size() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::hQueryCharacterExists(CharacterPacket* const argPacket) {
|
void World::hQueryCharacterExists(CharacterPacket* const argPacket) {
|
||||||
@@ -775,14 +755,6 @@ void World::hQueryCharacterExists(CharacterPacket* const argPacket) {
|
|||||||
std::cout << "Character Query, total: " << characterMap.size() << std::endl;
|
std::cout << "Character Query, total: " << characterMap.size() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::hQueryCharacterStats(CharacterPacket* const argPacket) {
|
|
||||||
//TODO: (9) World::hQueryCharacterStats()
|
|
||||||
}
|
|
||||||
|
|
||||||
void World::hQueryCharacterLocation(CharacterPacket* const argPacket) {
|
|
||||||
//TODO: (9) World::hQueryCharacterLocation()
|
|
||||||
}
|
|
||||||
|
|
||||||
void World::hCharacterMovement(CharacterPacket* const argPacket) {
|
void World::hCharacterMovement(CharacterPacket* const argPacket) {
|
||||||
//TODO: (1) Authentication
|
//TODO: (1) Authentication
|
||||||
if (argPacket->characterIndex == characterIndex) {
|
if (argPacket->characterIndex == characterIndex) {
|
||||||
@@ -799,110 +771,86 @@ void World::hCharacterMovement(CharacterPacket* const argPacket) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::hCharacterAttack(CharacterPacket* const argPacket) {
|
|
||||||
//TODO: (9) World::hCharacterAttack()
|
|
||||||
}
|
|
||||||
|
|
||||||
void World::hCharacterDamage(CharacterPacket* const argPacket) {
|
|
||||||
//TODO: (9) World::hCharacterDamage()
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
//monster management
|
//creature management
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
void World::hMonsterCreate(MonsterPacket* const argPacket) {
|
void World::hCreatureCreate(CreaturePacket* const argPacket) {
|
||||||
//check for logic errors
|
//check for logic errors
|
||||||
if (monsterMap.find(argPacket->monsterIndex) != monsterMap.end()) {
|
if (creatureMap.find(argPacket->creatureIndex) != creatureMap.end()) {
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
msg << "Double monster creation event; ";
|
msg << "Double creature creation event; ";
|
||||||
msg << "Index: " << argPacket->monsterIndex << "; ";
|
msg << "Index: " << argPacket->creatureIndex << "; ";
|
||||||
msg << "Handle: " << argPacket->handle;
|
msg << "Handle: " << argPacket->handle;
|
||||||
throw(std::runtime_error(msg.str()));
|
throw(std::runtime_error(msg.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//ignore monsters from other rooms
|
//ignore creatures from other rooms
|
||||||
if (roomIndex != argPacket->roomIndex) {
|
if (roomIndex != argPacket->roomIndex) {
|
||||||
//temporary error checking
|
//temporary error checking
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
msg << "Monster from the wrong room received: ";
|
msg << "Creature from the wrong room received: ";
|
||||||
msg << "monsterIndex: " << argPacket->monsterIndex << ", roomIndex: " << argPacket->roomIndex;
|
msg << "creatureIndex: " << argPacket->creatureIndex << ", roomIndex: " << argPacket->roomIndex;
|
||||||
throw(std::runtime_error(msg.str()));
|
throw(std::runtime_error(msg.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//implicitly create the element
|
//implicitly create the element
|
||||||
BaseMonster* monster = &monsterMap[argPacket->monsterIndex];
|
BaseCreature* creature = &creatureMap[argPacket->creatureIndex];
|
||||||
|
|
||||||
//fill the monster's info
|
//fill the creature's info
|
||||||
monster->SetHandle(argPacket->handle);
|
creature->SetHandle(argPacket->handle);
|
||||||
monster->SetAvatar(GetRenderer(), argPacket->avatar);
|
creature->SetAvatar(GetRenderer(), argPacket->avatar);
|
||||||
monster->SetBounds(argPacket->bounds);
|
creature->SetBounds(argPacket->bounds);
|
||||||
monster->SetOrigin(argPacket->origin);
|
creature->SetOrigin(argPacket->origin);
|
||||||
monster->SetMotion(argPacket->motion);
|
creature->SetMotion(argPacket->motion);
|
||||||
|
|
||||||
//debug
|
//debug
|
||||||
std::cout << "Monster Create, total: " << monsterMap.size() << std::endl;
|
std::cout << "Creature Create, total: " << creatureMap.size() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::hMonsterDelete(MonsterPacket* const argPacket) {
|
void World::hCreatureUnload(CreaturePacket* const argPacket) {
|
||||||
//ignore if this monster doesn't exist
|
//ignore if this creature doesn't exist
|
||||||
std::map<int, BaseMonster>::iterator monsterIt = monsterMap.find(argPacket->monsterIndex);
|
std::map<int, BaseCreature>::iterator creatureIt = creatureMap.find(argPacket->creatureIndex);
|
||||||
if (monsterIt == monsterMap.end()) {
|
if (creatureIt == creatureMap.end()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove this monster
|
//remove this creature
|
||||||
monsterMap.erase(monsterIt);
|
creatureMap.erase(creatureIt);
|
||||||
|
|
||||||
//debug
|
//debug
|
||||||
std::cout << "Monster Delete, total: " << monsterMap.size() << std::endl;
|
std::cout << "Creature Unload, total: " << creatureMap.size() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::hQueryMonsterExists(MonsterPacket* const argPacket) {
|
void World::hQueryCreatureExists(CreaturePacket* const argPacket) {
|
||||||
//ignore monsters in a different room (sub-optimal)
|
//ignore creatures in a different room (sub-optimal)
|
||||||
if (argPacket->roomIndex != roomIndex) {
|
if (argPacket->roomIndex != roomIndex) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//implicitly create the element
|
//implicitly create the element
|
||||||
BaseMonster* monster = &monsterMap[argPacket->monsterIndex];
|
BaseCreature* creature = &creatureMap[argPacket->creatureIndex];
|
||||||
|
|
||||||
//fill the monster's info
|
//fill the creature's info
|
||||||
monster->SetHandle(argPacket->handle);
|
creature->SetHandle(argPacket->handle);
|
||||||
monster->SetAvatar(GetRenderer(), argPacket->avatar);
|
creature->SetAvatar(GetRenderer(), argPacket->avatar);
|
||||||
monster->SetBounds(argPacket->bounds);
|
creature->SetBounds(argPacket->bounds);
|
||||||
monster->SetOrigin(argPacket->origin);
|
creature->SetOrigin(argPacket->origin);
|
||||||
monster->SetMotion(argPacket->motion);
|
creature->SetMotion(argPacket->motion);
|
||||||
|
|
||||||
//debug
|
//debug
|
||||||
std::cout << "Monster Query, total: " << monsterMap.size() << std::endl;
|
std::cout << "Creature Query, total: " << creatureMap.size() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::hQueryMonsterStats(MonsterPacket* const argPacket) {
|
void World::hCreatureMovement(CreaturePacket* const argPacket) {
|
||||||
//TODO: (9) World::hQueryMonsterStats()
|
//ignore if this creature doesn't exist
|
||||||
}
|
std::map<int, BaseCreature>::iterator creatureIt = creatureMap.find(argPacket->creatureIndex);
|
||||||
|
if (creatureIt == creatureMap.end()) {
|
||||||
void World::hQueryMonsterLocation(MonsterPacket* const argPacket) {
|
|
||||||
//TODO: (9) World::hQueryMonsterLocation()
|
|
||||||
}
|
|
||||||
|
|
||||||
void World::hMonsterMovement(MonsterPacket* const argPacket) {
|
|
||||||
//ignore if this monster doesn't exist
|
|
||||||
std::map<int, BaseMonster>::iterator monsterIt = monsterMap.find(argPacket->monsterIndex);
|
|
||||||
if (monsterIt == monsterMap.end()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
monsterIt->second.SetOrigin(argPacket->origin);
|
creatureIt->second.SetOrigin(argPacket->origin);
|
||||||
monsterIt->second.SetOrigin(argPacket->motion);
|
creatureIt->second.SetMotion(argPacket->motion);
|
||||||
}
|
|
||||||
|
|
||||||
void World::hMonsterAttack(MonsterPacket* const argPacket) {
|
|
||||||
//TODO: (9) World::hMonsterAttack()
|
|
||||||
}
|
|
||||||
|
|
||||||
void World::hMonsterDamage(MonsterPacket* const argPacket) {
|
|
||||||
//TODO: (9) World::hMonsterDamage()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|||||||
+9
-16
@@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
//client
|
//client
|
||||||
#include "base_scene.hpp"
|
#include "base_scene.hpp"
|
||||||
#include "base_monster.hpp"
|
#include "base_creature.hpp"
|
||||||
#include "local_character.hpp"
|
#include "local_character.hpp"
|
||||||
|
|
||||||
#include "SDL2/SDL.h"
|
#include "SDL2/SDL.h"
|
||||||
@@ -102,25 +102,18 @@ private:
|
|||||||
//character management
|
//character management
|
||||||
void hCharacterUpdate(CharacterPacket* const);
|
void hCharacterUpdate(CharacterPacket* const);
|
||||||
void hCharacterCreate(CharacterPacket* const);
|
void hCharacterCreate(CharacterPacket* const);
|
||||||
void hCharacterDelete(CharacterPacket* const);
|
void hCharacterUnload(CharacterPacket* const);
|
||||||
void hQueryCharacterExists(CharacterPacket* const);
|
void hQueryCharacterExists(CharacterPacket* const);
|
||||||
void hQueryCharacterStats(CharacterPacket* const);
|
|
||||||
void hQueryCharacterLocation(CharacterPacket* const);
|
|
||||||
void hCharacterMovement(CharacterPacket* const);
|
void hCharacterMovement(CharacterPacket* const);
|
||||||
void hCharacterAttack(CharacterPacket* const);
|
|
||||||
void hCharacterDamage(CharacterPacket* const);
|
|
||||||
|
|
||||||
//monster management
|
//creature management
|
||||||
void hMonsterCreate(MonsterPacket* const);
|
void hCreatureCreate(CreaturePacket* const);
|
||||||
void hMonsterDelete(MonsterPacket* const);
|
void hCreatureUnload(CreaturePacket* const);
|
||||||
void hQueryMonsterExists(MonsterPacket* const);
|
void hQueryCreatureExists(CreaturePacket* const);
|
||||||
void hQueryMonsterStats(MonsterPacket* const);
|
void hCreatureMovement(CreaturePacket* const);
|
||||||
void hQueryMonsterLocation(MonsterPacket* const);
|
|
||||||
void hMonsterMovement(MonsterPacket* const);
|
|
||||||
void hMonsterAttack(MonsterPacket* const);
|
|
||||||
void hMonsterDamage(MonsterPacket* const);
|
|
||||||
|
|
||||||
//chat
|
//chat
|
||||||
|
//TODO: ui chat engine
|
||||||
void hTextBroadcast(TextPacket* const);
|
void hTextBroadcast(TextPacket* const);
|
||||||
void hTextSpeech(TextPacket* const);
|
void hTextSpeech(TextPacket* const);
|
||||||
void hTextWhisper(TextPacket* const);
|
void hTextWhisper(TextPacket* const);
|
||||||
@@ -158,7 +151,7 @@ private:
|
|||||||
|
|
||||||
//entities
|
//entities
|
||||||
std::map<int, BaseCharacter> characterMap;
|
std::map<int, BaseCharacter> characterMap;
|
||||||
std::map<int, BaseMonster> monsterMap;
|
std::map<int, BaseCreature> creatureMap;
|
||||||
LocalCharacter* localCharacter = nullptr;
|
LocalCharacter* localCharacter = nullptr;
|
||||||
|
|
||||||
//heartbeat
|
//heartbeat
|
||||||
|
|||||||
@@ -134,8 +134,11 @@ enum class SerialPacketType {
|
|||||||
CREATURE_CREATE = 502,
|
CREATURE_CREATE = 502,
|
||||||
CREATURE_UNLOAD = 503,
|
CREATURE_UNLOAD = 503,
|
||||||
|
|
||||||
|
//find out info from the server
|
||||||
|
QUERY_CREATURE_EXISTS = 504,
|
||||||
|
|
||||||
//actions taken
|
//actions taken
|
||||||
CREATURE_MOVEMENT = 504,
|
CREATURE_MOVEMENT = 505,
|
||||||
|
|
||||||
FORMAT_END_CREATURE = 599,
|
FORMAT_END_CREATURE = 599,
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
config.next = rsc\config.cfg
|
||||||
|
|
||||||
|
#debugging
|
||||||
|
server.name = DEV
|
||||||
|
|
||||||
|
client.username = Ratstail91
|
||||||
|
client.handle = Female Character
|
||||||
|
client.avatar = character2.png
|
||||||
@@ -136,6 +136,7 @@ void ServerApplication::Init(int argc, char* argv[]) {
|
|||||||
|
|
||||||
std::cout << "Internal sizes:" << std::endl;
|
std::cout << "Internal sizes:" << std::endl;
|
||||||
|
|
||||||
|
DEBUG_INTERNAL_VAR(config["server.name"]);
|
||||||
DEBUG_INTERNAL_VAR(NETWORK_VERSION);
|
DEBUG_INTERNAL_VAR(NETWORK_VERSION);
|
||||||
DEBUG_INTERNAL_VAR(sizeof(Region::type_t));
|
DEBUG_INTERNAL_VAR(sizeof(Region::type_t));
|
||||||
DEBUG_INTERNAL_VAR(sizeof(Region));
|
DEBUG_INTERNAL_VAR(sizeof(Region));
|
||||||
@@ -303,6 +304,10 @@ void ServerApplication::HandlePacket(SerialPacket* const argPacket) {
|
|||||||
hCharacterMovement(static_cast<CharacterPacket*>(argPacket));
|
hCharacterMovement(static_cast<CharacterPacket*>(argPacket));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SerialPacketType::QUERY_CREATURE_EXISTS:
|
||||||
|
//TODO: creature queries
|
||||||
|
break;
|
||||||
|
|
||||||
//chat
|
//chat
|
||||||
case SerialPacketType::TEXT_BROADCAST:
|
case SerialPacketType::TEXT_BROADCAST:
|
||||||
hTextBroadcast(static_cast<TextPacket*>(argPacket));
|
hTextBroadcast(static_cast<TextPacket*>(argPacket));
|
||||||
@@ -656,9 +661,9 @@ void ServerApplication::hCharacterDelete(CharacterPacket* const argPacket) {
|
|||||||
CharacterData* characterData = characterMgr.Get(characterIndex);
|
CharacterData* characterData = characterMgr.Get(characterIndex);
|
||||||
roomMgr.PopCharacter(characterData);
|
roomMgr.PopCharacter(characterData);
|
||||||
|
|
||||||
//pump character delete
|
//pump character unload
|
||||||
CharacterPacket newPacket;
|
CharacterPacket newPacket;
|
||||||
newPacket.type = SerialPacketType::CHARACTER_DELETE;
|
newPacket.type = SerialPacketType::CHARACTER_UNLOAD;
|
||||||
newPacket.characterIndex = characterIndex;
|
newPacket.characterIndex = characterIndex;
|
||||||
pumpPacketProximity(static_cast<SerialPacket*>(&newPacket), characterData->GetRoomIndex());
|
pumpPacketProximity(static_cast<SerialPacket*>(&newPacket), characterData->GetRoomIndex());
|
||||||
|
|
||||||
@@ -728,7 +733,7 @@ void ServerApplication::hCharacterUnload(CharacterPacket* const argPacket) {
|
|||||||
|
|
||||||
//pump character delete
|
//pump character delete
|
||||||
CharacterPacket newPacket;
|
CharacterPacket newPacket;
|
||||||
newPacket.type = SerialPacketType::CHARACTER_DELETE;
|
newPacket.type = SerialPacketType::CHARACTER_UNLOAD;
|
||||||
newPacket.characterIndex = argPacket->characterIndex;
|
newPacket.characterIndex = argPacket->characterIndex;
|
||||||
pumpPacketProximity(static_cast<SerialPacket*>(&newPacket), characterData->GetRoomIndex());
|
pumpPacketProximity(static_cast<SerialPacket*>(&newPacket), characterData->GetRoomIndex());
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ void fullCharacterUnload(int index) {
|
|||||||
|
|
||||||
//pump character unload
|
//pump character unload
|
||||||
CharacterPacket newPacket;
|
CharacterPacket newPacket;
|
||||||
newPacket.type = SerialPacketType::CHARACTER_DELETE;
|
newPacket.type = SerialPacketType::CHARACTER_UNLOAD;
|
||||||
newPacket.characterIndex = characterPair.first;
|
newPacket.characterIndex = characterPair.first;
|
||||||
//NOTE: more character info as needed
|
//NOTE: more character info as needed
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ void pumpAndChangeRooms(CharacterData* const characterData, int newRoomIndex, in
|
|||||||
//delete from the old room
|
//delete from the old room
|
||||||
CharacterPacket newPacket;
|
CharacterPacket newPacket;
|
||||||
copyCharacterToPacket(&newPacket, characterData, characterIndex);
|
copyCharacterToPacket(&newPacket, characterData, characterIndex);
|
||||||
newPacket.type = SerialPacketType::CHARACTER_DELETE;
|
newPacket.type = SerialPacketType::CHARACTER_UNLOAD;
|
||||||
pumpPacketProximity(&newPacket, characterData->GetRoomIndex());
|
pumpPacketProximity(&newPacket, characterData->GetRoomIndex());
|
||||||
|
|
||||||
//move the character between rooms
|
//move the character between rooms
|
||||||
|
|||||||
Reference in New Issue
Block a user