diff --git a/client/client_application.cpp b/client/client_application.cpp index 4ae481b..3d287fc 100644 --- a/client/client_application.cpp +++ b/client/client_application.cpp @@ -38,8 +38,7 @@ #include "options_menu.hpp" #include "lobby_menu.hpp" #include "in_world.hpp" -//#include "in_combat.hpp" -#include "clean_up.hpp" +#include "disconnected_screen.hpp" //------------------------- //Public access members @@ -179,16 +178,13 @@ void ClientApplication::LoadScene(SceneList sceneIndex) { activeScene = new OptionsMenu(); break; case SceneList::LOBBYMENU: - activeScene = new LobbyMenu(&clientIndex, &accountIndex); + activeScene = new LobbyMenu(&clientIndex, &accountIndex); //TODO: can I use the ConfigUtility for these parameters? break; case SceneList::INWORLD: - activeScene = new InWorld(&clientIndex, &accountIndex, &characterIndex, &characterMap); + activeScene = new InWorld(&clientIndex, &accountIndex); break; -// case SceneList::INCOMBAT: -// activeScene = new InCombat(&clientIndex, &accountIndex, &characterIndex, &characterMap); -// break; - case SceneList::CLEANUP: - activeScene = new CleanUp(&clientIndex, &accountIndex, &characterIndex, &characterMap); + case SceneList::DISCONNECTEDSCREEN: + activeScene = new DisconnectedScreen(); break; default: throw(std::logic_error("Failed to recognize the scene index")); diff --git a/client/client_application.hpp b/client/client_application.hpp index dbbc785..7e99458 100644 --- a/client/client_application.hpp +++ b/client/client_application.hpp @@ -26,7 +26,6 @@ #include "base_scene.hpp" #include "udp_network_utility.hpp" -#include "character.hpp" #include "singleton.hpp" @@ -54,9 +53,6 @@ private: //shared parameters int clientIndex = -1; int accountIndex = -1; - int characterIndex = -1; - - CharacterMap characterMap; }; #endif diff --git a/client/makefile b/client/makefile index c46fbcb..ade60d1 100644 --- a/client/makefile +++ b/client/makefile @@ -1,5 +1,5 @@ #config -INCLUDES+=. client_utilities scenes ../common/debugging ../common/gameplay ../common/graphics ../common/map ../common/network ../common/network/packet_types ../common/ui ../common/utilities +INCLUDES+=. client_utilities renderable scenes ../common/debugging ../common/gameplay ../common/graphics ../common/map ../common/network ../common/network/packet_types ../common/ui ../common/utilities LIBS+=client.a ../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) @@ -18,6 +18,7 @@ OUT=$(addprefix $(OUTDIR)/,client) all: $(OBJ) $(OUT) $(MAKE) -C client_utilities $(MAKE) -C scenes + $(MAKE) -C renderable $(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS) $(OBJ): | $(OBJDIR) diff --git a/client/character.cpp b/client/renderable/base_character.cpp similarity index 77% rename from client/character.cpp rename to client/renderable/base_character.cpp index 70ee4a9..ad31e92 100644 --- a/client/character.cpp +++ b/client/renderable/base_character.cpp @@ -19,23 +19,9 @@ * 3. This notice may not be removed or altered from any source * distribution. */ -#include "character.hpp" +#include "base_character.hpp" -void Character::Update() { - if (motion.x && motion.y) { - origin += motion * CHARACTER_WALKING_MOD; - } - else if (motion != 0) { - origin += motion; - } - sprite.Update(0.016); -} - -void Character::DrawTo(SDL_Surface* const dest, int camX, int camY) { - sprite.DrawTo(dest, origin.x - camX, origin.y - camY); -} - -void Character::CorrectSprite() { +void BaseCharacter::CorrectSprite() { //NOTE: These must correspond to the sprite sheet in use if (motion.y > 0) { sprite.SetYIndex(0); diff --git a/client/character.hpp b/client/renderable/base_character.hpp similarity index 57% rename from client/character.hpp rename to client/renderable/base_character.hpp index 6be3cc6..1531ba3 100644 --- a/client/character.hpp +++ b/client/renderable/base_character.hpp @@ -19,38 +19,23 @@ * 3. This notice may not be removed or altered from any source * distribution. */ -#ifndef CHARACTER_HPP_ -#define CHARACTER_HPP_ +#ifndef BASECHARACTER_HPP_ +#define BASECHARACTER_HPP_ //components #include "character_defines.hpp" -#include "vector2.hpp" -#include "bounding_box.hpp" -#include "statistics.hpp" - -//graphics -#include "sprite_sheet.hpp" +#include "renderable.hpp" //std namespace #include -#include -class Character { +class BaseCharacter : public Renderable { public: - Character() = default; - ~Character() = default; - - void Update(); + BaseCharacter() = default; + virtual ~BaseCharacter() = default; //graphics - void DrawTo(SDL_Surface* const, int camX, int camY); void CorrectSprite(); - SpriteSheet* GetSprite() { return &sprite; } - - //gameplay - Statistics* GetStats() { return &stats; } - - //accessors and mutators //metadata int SetOwner(int i) { return owner = i; } @@ -60,36 +45,11 @@ public: std::string SetAvatar(std::string s) { return avatar = s; } std::string GetAvatar() const { return avatar; } - //position - Vector2 SetOrigin(Vector2 v) { return origin = v; } - Vector2 GetOrigin() const { return origin; } - Vector2 SetMotion(Vector2 v) { return motion = v; } - Vector2 GetMotion() const { return motion; } - BoundingBox SetBounds(BoundingBox b) { return bounds = b; } - BoundingBox GetBounds() { return bounds; } - private: - //graphics - SpriteSheet sprite; - - //base statistics - Statistics stats; - - //gameplay components: equipment, items, buffs, debuffs... - //metadata int owner; std::string handle; std::string avatar; - - //position - Vector2 origin = {0.0,0.0}; - Vector2 motion = {0.0,0.0}; - BoundingBox bounds; }; -//tmp -#include -typedef std::map CharacterMap; - #endif diff --git a/client/renderable/base_monster.cpp b/client/renderable/base_monster.cpp new file mode 100644 index 0000000..e6350c4 --- /dev/null +++ b/client/renderable/base_monster.cpp @@ -0,0 +1,23 @@ +/* Copyright: (c) Kayne Ruse 2014 + * + * 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 "base_monster.hpp" + diff --git a/common/gameplay/combat_defines.hpp b/client/renderable/base_monster.hpp similarity index 83% rename from common/gameplay/combat_defines.hpp rename to client/renderable/base_monster.hpp index db6421c..58d8f49 100644 --- a/common/gameplay/combat_defines.hpp +++ b/client/renderable/base_monster.hpp @@ -19,16 +19,18 @@ * 3. This notice may not be removed or altered from any source * distribution. */ -#ifndef COMBATDEFINES_HPP_ -#define COMBATDEFINES_HPP_ +#ifndef BASEMONSTER_HPP_ +#define BASEMONSTER_HPP_ -#define COMBAT_MAX_CHARACTERS 16 -#define COMBAT_MAX_ENEMIES 16 +#include "renderable.hpp" -enum class TerrainType { - NONE = 0, - GRASSLANDS, - //etc. +class BaseMonster { +public: + BaseMonster(); + virtual ~BaseMonster(); + +private: + // }; -#endif +#endif \ No newline at end of file diff --git a/client/renderable/local_character.cpp b/client/renderable/local_character.cpp new file mode 100644 index 0000000..211a6bc --- /dev/null +++ b/client/renderable/local_character.cpp @@ -0,0 +1,23 @@ +/* Copyright: (c) Kayne Ruse 2014 + * + * 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 "local_character.hpp" + diff --git a/client/renderable/local_character.hpp b/client/renderable/local_character.hpp new file mode 100644 index 0000000..8407fef --- /dev/null +++ b/client/renderable/local_character.hpp @@ -0,0 +1,40 @@ +/* Copyright: (c) Kayne Ruse 2014 + * + * 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 LOCALCHARACTER_HPP_ +#define LOCALCHARACTER_HPP_ + +#include "base_character.hpp" +#include "statistics.hpp" + +class LocalCharacter : public BaseCharacter { +public: + LocalCharacter() = default; + ~LocalCharacter() = default; + + Statistics* GetBaseStats() { return &baseStats; } + +private: + Statistics baseStats; + //TODO: weapons, armour, buffs, debuffs, etc. +}; + +#endif diff --git a/client/renderable/makefile b/client/renderable/makefile new file mode 100644 index 0000000..a426eda --- /dev/null +++ b/client/renderable/makefile @@ -0,0 +1,37 @@ +#config +INCLUDES+=. .. ../../common/gameplay ../../common/graphics ../../common/utilities +LIBS+= +CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) + +#source +CXXSRC=$(wildcard *.cpp) + +#objects +OBJDIR=obj +OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o)) + +#output +OUTDIR=.. +OUT=$(addprefix $(OUTDIR)/,client.a) + +#targets +all: $(OBJ) $(OUT) + ar -crs $(OUT) $(OBJ) + +$(OBJ): | $(OBJDIR) + +$(OUT): | $(OUTDIR) + +$(OBJDIR): + mkdir $(OBJDIR) + +$(OUTDIR): + mkdir $(OUTDIR) + +$(OBJDIR)/%.o: %.cpp + $(CXX) $(CXXFLAGS) -c -o $@ $< + +clean: + $(RM) *.o *.a *.exe + +rebuild: clean all diff --git a/client/renderable/renderable.cpp b/client/renderable/renderable.cpp new file mode 100644 index 0000000..46d319d --- /dev/null +++ b/client/renderable/renderable.cpp @@ -0,0 +1,31 @@ +/* Copyright: (c) Kayne Ruse 2014 + * + * 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 "renderable.hpp" + +void Renderable::Update() { + origin += motion; + sprite.Update(0.016); +} + +void Renderable::DrawTo(SDL_Surface* const dest, int camX, int camY) { + sprite.DrawTo(dest, origin.x - camX, origin.y - camY); +} \ No newline at end of file diff --git a/client/renderable/renderable.hpp b/client/renderable/renderable.hpp new file mode 100644 index 0000000..d78cde2 --- /dev/null +++ b/client/renderable/renderable.hpp @@ -0,0 +1,56 @@ +/* Copyright: (c) Kayne Ruse 2014 + * + * 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 RENDERABLE_HPP_ +#define RENDERABLE_HPP_ + +#include "bounding_box.hpp" +#include "sprite_sheet.hpp" +#include "vector2.hpp" + +class Renderable { +public: + Renderable() = default; + virtual ~Renderable() = default; + + virtual void Update(); + virtual void DrawTo(SDL_Surface* const, int camX, int camY); + + SpriteSheet* GetSprite() { return &sprite; } + + //position + Vector2 SetOrigin(Vector2 v) { return origin = v; } + Vector2 GetOrigin() const { return origin; } + Vector2 SetMotion(Vector2 v) { return motion = v; } + Vector2 GetMotion() const { return motion; } + + //collision + BoundingBox SetBounds(BoundingBox b) { return bounds = b; } + BoundingBox GetBounds() { return bounds; } + +protected: //TODO: should be private + SpriteSheet sprite; + Vector2 origin = {0, 0}; + Vector2 motion = {0, 0}; + BoundingBox bounds; +}; + +#endif \ No newline at end of file diff --git a/client/scene_list.hpp b/client/scene_list.hpp index 804b9c9..82895cd 100644 --- a/client/scene_list.hpp +++ b/client/scene_list.hpp @@ -34,8 +34,7 @@ enum class SceneList { OPTIONSMENU, LOBBYMENU, INWORLD, - INCOMBAT, - CLEANUP, + DISCONNECTEDSCREEN, }; #endif diff --git a/client/scenes/clean_up.cpp b/client/scenes/disconnected_screen.cpp similarity index 72% rename from client/scenes/clean_up.cpp rename to client/scenes/disconnected_screen.cpp index 54ced25..7d95293 100644 --- a/client/scenes/clean_up.cpp +++ b/client/scenes/disconnected_screen.cpp @@ -19,10 +19,11 @@ * 3. This notice may not be removed or altered from any source * distribution. */ -#include "clean_up.hpp" +#include "disconnected_screen.hpp" #include "channels.hpp" #include "config_utility.hpp" +#include "udp_network_utility.hpp" #include @@ -30,17 +31,7 @@ //Public access members //------------------------- -CleanUp::CleanUp( - int* const argClientIndex, - int* const argAccountIndex, - int* const argCharacterIndex, - CharacterMap* argCharacterMap - ): - clientIndex(*argClientIndex), - accountIndex(*argAccountIndex), - characterIndex(*argCharacterIndex), - characterMap(*argCharacterMap) -{ +DisconnectedScreen::DisconnectedScreen() { ConfigUtility& config = ConfigUtility::GetSingleton(); //setup the utility objects @@ -60,19 +51,13 @@ CleanUp::CleanUp( backButton.SetText("Back"); //full reset - network.Unbind(Channels::SERVER); - clientIndex = -1; - accountIndex = -1; - characterIndex = -1; -// combatMap.clear(); - characterMap.clear(); -// enemyMap.clear(); + UDPNetworkUtility::GetSingleton().Unbind(Channels::SERVER); //auto return startTick = std::chrono::steady_clock::now(); } -CleanUp::~CleanUp() { +DisconnectedScreen::~DisconnectedScreen() { // } @@ -80,16 +65,16 @@ CleanUp::~CleanUp() { //Frame loop //------------------------- -void CleanUp::Update() { +void DisconnectedScreen::Update() { if (std::chrono::steady_clock::now() - startTick > std::chrono::duration(10)) { SetNextScene(SceneList::MAINMENU); } //Eat incoming packets - while(network.Receive()); + while(UDPNetworkUtility::GetSingleton().Receive()); } -void CleanUp::Render(SDL_Surface* const screen) { +void DisconnectedScreen::Render(SDL_Surface* const screen) { ConfigUtility& config = ConfigUtility::GetSingleton(); backButton.DrawTo(screen); @@ -100,25 +85,25 @@ void CleanUp::Render(SDL_Surface* const screen) { //Event handlers //------------------------- -void CleanUp::QuitEvent() { +void DisconnectedScreen::QuitEvent() { SetNextScene(SceneList::QUIT); } -void CleanUp::MouseMotion(SDL_MouseMotionEvent const& motion) { +void DisconnectedScreen::MouseMotion(SDL_MouseMotionEvent const& motion) { backButton.MouseMotion(motion); } -void CleanUp::MouseButtonDown(SDL_MouseButtonEvent const& button) { +void DisconnectedScreen::MouseButtonDown(SDL_MouseButtonEvent const& button) { backButton.MouseButtonDown(button); } -void CleanUp::MouseButtonUp(SDL_MouseButtonEvent const& button) { +void DisconnectedScreen::MouseButtonUp(SDL_MouseButtonEvent const& button) { if (backButton.MouseButtonUp(button) == Button::State::HOVER) { SetNextScene(SceneList::MAINMENU); } } -void CleanUp::KeyDown(SDL_KeyboardEvent const& key) { +void DisconnectedScreen::KeyDown(SDL_KeyboardEvent const& key) { switch(key.keysym.sym) { case SDLK_ESCAPE: SetNextScene(SceneList::MAINMENU); @@ -126,6 +111,6 @@ void CleanUp::KeyDown(SDL_KeyboardEvent const& key) { } } -void CleanUp::KeyUp(SDL_KeyboardEvent const& key) { +void DisconnectedScreen::KeyUp(SDL_KeyboardEvent const& key) { // } diff --git a/client/scenes/clean_up.hpp b/client/scenes/disconnected_screen.hpp similarity index 76% rename from client/scenes/clean_up.hpp rename to client/scenes/disconnected_screen.hpp index a408d3d..453dad8 100644 --- a/client/scenes/clean_up.hpp +++ b/client/scenes/disconnected_screen.hpp @@ -19,11 +19,8 @@ * 3. This notice may not be removed or altered from any source * distribution. */ -#ifndef CLEANUP_HPP_ -#define CLEANUP_HPP_ - -//network -#include "udp_network_utility.hpp" +#ifndef DISCONNECTEDSCREEN_HPP_ +#define DISCONNECTEDSCREEN_HPP_ //graphics #include "image.hpp" @@ -31,22 +28,16 @@ #include "button.hpp" //client -#include "character.hpp" #include "base_scene.hpp" //std namespace #include -class CleanUp : public BaseScene { +class DisconnectedScreen : public BaseScene { public: //Public access members - CleanUp( - int* const argClientIndex, - int* const argAccountIndex, - int* const argCharacterIndex, - CharacterMap* argCharacterMap - ); - ~CleanUp(); + DisconnectedScreen(); + ~DisconnectedScreen(); protected: //Frame loop @@ -61,13 +52,6 @@ protected: void KeyDown(SDL_KeyboardEvent const&); void KeyUp(SDL_KeyboardEvent const&); - //shared parameters - UDPNetworkUtility& network = UDPNetworkUtility::GetSingleton(); - int& clientIndex; - int& accountIndex; - int& characterIndex; - CharacterMap& characterMap; - //graphics Image image; RasterFont font; diff --git a/client/scenes/in_world.cpp b/client/scenes/in_world.cpp index 028d5bd..4581b1a 100644 --- a/client/scenes/in_world.cpp +++ b/client/scenes/in_world.cpp @@ -34,16 +34,9 @@ //Public access members //------------------------- -InWorld::InWorld( - int* const argClientIndex, - int* const argAccountIndex, - int* const argCharacterIndex, - CharacterMap* argCharacterMap - ): +InWorld::InWorld(int* const argClientIndex, int* const argAccountIndex): clientIndex(*argClientIndex), - accountIndex(*argAccountIndex), - characterIndex(*argCharacterIndex), - characterMap(*argCharacterMap) + accountIndex(*argAccountIndex) { ConfigUtility& config = ConfigUtility::GetSingleton(); @@ -153,7 +146,7 @@ void InWorld::Update() { if (Clock::now() - lastBeat > std::chrono::seconds(3)) { if (attemptedBeats > 2) { RequestDisconnect(); - SetNextScene(SceneList::CLEANUP); + SetNextScene(SceneList::DISCONNECTEDSCREEN); ConfigUtility::GetSingleton()["client.disconnectMessage"] = "Error: Lost connection to the server"; } @@ -342,7 +335,7 @@ void InWorld::HandlePong(ServerPacket* const argPacket) { void InWorld::HandleDisconnect(ClientPacket* const argPacket) { //TODO: More needed in the disconnection - SetNextScene(SceneList::CLEANUP); + SetNextScene(SceneList::DISCONNECTEDSCREEN); ConfigUtility::GetSingleton()["client.disconnectMessage"] = "You have been disconnected"; } @@ -352,7 +345,7 @@ void InWorld::HandleCharacterNew(CharacterPacket* const argPacket) { } //create the character object - Character& newCharacter = characterMap[argPacket->characterIndex]; + BaseCharacter& newCharacter = characterMap[argPacket->characterIndex]; //fill out the character's members newCharacter.SetHandle(argPacket->handle); @@ -369,7 +362,7 @@ void InWorld::HandleCharacterNew(CharacterPacket* const argPacket) { CHARACTER_BOUNDS_HEIGHT }); - (*newCharacter.GetStats()) = argPacket->stats; +// (*newCharacter.GetBaseStats()) = argPacket->stats; //bookkeeping code newCharacter.CorrectSprite(); @@ -407,7 +400,7 @@ void InWorld::HandleCharacterUpdate(CharacterPacket* const argPacket) { return; } - Character& character = characterMap[argPacket->characterIndex]; + BaseCharacter& character = characterMap[argPacket->characterIndex]; //other characters moving if (argPacket->characterIndex != characterIndex) { @@ -419,7 +412,7 @@ void InWorld::HandleCharacterUpdate(CharacterPacket* const argPacket) { void InWorld::HandleCharacterRejection(TextPacket* const argPacket) { RequestDisconnect(); - SetNextScene(SceneList::CLEANUP); + SetNextScene(SceneList::DISCONNECTEDSCREEN); ConfigUtility& config = ConfigUtility::GetSingleton(); config["client.disconnectMessage"] = "Error: "; config["client.disconnectMessage"] += argPacket->text; @@ -464,7 +457,7 @@ void InWorld::SendPlayerUpdate() { newPacket.roomIndex = 0; //TODO: room index newPacket.origin = localCharacter->GetOrigin(); newPacket.motion = localCharacter->GetMotion(); - newPacket.stats = *localCharacter->GetStats(); +// newPacket.stats = *localCharacter->GetBaseStats(); //TODO: gameplay components: equipment, items, buffs, debuffs diff --git a/client/scenes/in_world.hpp b/client/scenes/in_world.hpp index d80659d..62904d9 100644 --- a/client/scenes/in_world.hpp +++ b/client/scenes/in_world.hpp @@ -38,7 +38,8 @@ //common #include "frame_rate.hpp" -#include "character.hpp" +#include "base_character.hpp" +#include "local_character.hpp" //client #include "base_scene.hpp" @@ -51,12 +52,7 @@ class InWorld : public BaseScene { public: //Public access members - InWorld( - int* const argClientIndex, - int* const argAccountIndex, - int* const argCharacterIndex, - CharacterMap* argCharacterMap - ); + InWorld(int* const argClientIndex, int* const argAccountIndex); ~InWorld(); protected: @@ -100,8 +96,8 @@ protected: UDPNetworkUtility& network = UDPNetworkUtility::GetSingleton(); int& clientIndex; int& accountIndex; - int& characterIndex; - CharacterMap& characterMap; + int characterIndex = -1; + std::map characterMap; //graphics Image buttonImage; @@ -124,7 +120,7 @@ protected: FrameRate fps; //game - Character* localCharacter = nullptr; + BaseCharacter* localCharacter = nullptr; //connections //TODO: This needs it's own utility, for both InWorld and InCombat diff --git a/client/scenes/lobby_menu.cpp b/client/scenes/lobby_menu.cpp index 7346f45..c679f96 100644 --- a/client/scenes/lobby_menu.cpp +++ b/client/scenes/lobby_menu.cpp @@ -34,6 +34,10 @@ LobbyMenu::LobbyMenu(int* const argClientIndex, int* const argAccountIndex): clientIndex(*argClientIndex), accountIndex(*argAccountIndex) { + //preemptive reset + clientIndex = -1; + accountIndex = -1; + //setup the utility objects image.LoadSurface(config["dir.interface"] + "button_menu.bmp"); image.SetClipH(image.GetClipH()/3); diff --git a/client/scenes/makefile b/client/scenes/makefile index f8d8358..7a59128 100644 --- a/client/scenes/makefile +++ b/client/scenes/makefile @@ -1,5 +1,5 @@ #config -INCLUDES+=. .. ../../common/gameplay ../../common/graphics ../../common/map ../../common/network ../../common/network/packet_types ../../common/ui ../../common/utilities +INCLUDES+=. .. ../renderable ../../common/gameplay ../../common/graphics ../../common/map ../../common/network ../../common/network/packet_types ../../common/ui ../../common/utilities LIBS+= CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) diff --git a/common/gameplay/character_defines.hpp b/common/gameplay/character_defines.hpp index 484fcfa..d5ca3b6 100644 --- a/common/gameplay/character_defines.hpp +++ b/common/gameplay/character_defines.hpp @@ -27,6 +27,7 @@ //the speeds that the characters move constexpr double CHARACTER_WALKING_SPEED = 2.24; constexpr double CHARACTER_WALKING_MOD = 1.0/sqrt(2.0); +constexpr double CHARACTER_WALKING_NEGATIVE_MOD = 1.0 - CHARACTER_WALKING_MOD; //the bounds for the character objects, mapped to the default sprites constexpr int CHARACTER_BOUNDS_X = 0;