Characters are working correctly again

This commit is contained in:
Kayne Ruse
2014-06-14 23:13:11 +10:00
parent c021032512
commit a23fbbfb38
5 changed files with 14 additions and 19 deletions
+11 -2
View File
@@ -128,7 +128,7 @@ void InWorld::RenderFrame() {
} }
void InWorld::Render(SDL_Surface* const screen) { void InWorld::Render(SDL_Surface* const screen) {
//draw the map0 //draw the map
for (std::list<Region>::iterator it = regionPager.GetContainer()->begin(); it != regionPager.GetContainer()->end(); it++) { for (std::list<Region>::iterator it = regionPager.GetContainer()->begin(); it != regionPager.GetContainer()->end(); it++) {
tileSheet.DrawRegionTo(screen, &(*it), camera.x, camera.y); tileSheet.DrawRegionTo(screen, &(*it), camera.x, camera.y);
} }
@@ -185,6 +185,7 @@ void InWorld::KeyDown(SDL_KeyboardEvent const& key) {
case SDLK_LEFT: case SDLK_LEFT:
if (localCharacter) { if (localCharacter) {
localCharacter->motion.x -= CHARACTER_WALKING_SPEED; localCharacter->motion.x -= CHARACTER_WALKING_SPEED;
localCharacter->CorrectSprite();
SendPlayerUpdate(); SendPlayerUpdate();
} }
break; break;
@@ -192,6 +193,7 @@ void InWorld::KeyDown(SDL_KeyboardEvent const& key) {
case SDLK_RIGHT: case SDLK_RIGHT:
if (localCharacter) { if (localCharacter) {
localCharacter->motion.x += CHARACTER_WALKING_SPEED; localCharacter->motion.x += CHARACTER_WALKING_SPEED;
localCharacter->CorrectSprite();
SendPlayerUpdate(); SendPlayerUpdate();
} }
break; break;
@@ -199,6 +201,7 @@ void InWorld::KeyDown(SDL_KeyboardEvent const& key) {
case SDLK_UP: case SDLK_UP:
if (localCharacter) { if (localCharacter) {
localCharacter->motion.y -= CHARACTER_WALKING_SPEED; localCharacter->motion.y -= CHARACTER_WALKING_SPEED;
localCharacter->CorrectSprite();
SendPlayerUpdate(); SendPlayerUpdate();
} }
break; break;
@@ -206,6 +209,7 @@ void InWorld::KeyDown(SDL_KeyboardEvent const& key) {
case SDLK_DOWN: case SDLK_DOWN:
if (localCharacter) { if (localCharacter) {
localCharacter->motion.y += CHARACTER_WALKING_SPEED; localCharacter->motion.y += CHARACTER_WALKING_SPEED;
localCharacter->CorrectSprite();
SendPlayerUpdate(); SendPlayerUpdate();
} }
break; break;
@@ -218,6 +222,7 @@ void InWorld::KeyUp(SDL_KeyboardEvent const& key) {
case SDLK_LEFT: case SDLK_LEFT:
if (localCharacter) { if (localCharacter) {
localCharacter->motion.x += CHARACTER_WALKING_SPEED; localCharacter->motion.x += CHARACTER_WALKING_SPEED;
localCharacter->CorrectSprite();
SendPlayerUpdate(); SendPlayerUpdate();
} }
break; break;
@@ -225,6 +230,7 @@ void InWorld::KeyUp(SDL_KeyboardEvent const& key) {
case SDLK_RIGHT: case SDLK_RIGHT:
if (localCharacter) { if (localCharacter) {
localCharacter->motion.x -= CHARACTER_WALKING_SPEED; localCharacter->motion.x -= CHARACTER_WALKING_SPEED;
localCharacter->CorrectSprite();
SendPlayerUpdate(); SendPlayerUpdate();
} }
break; break;
@@ -232,6 +238,7 @@ void InWorld::KeyUp(SDL_KeyboardEvent const& key) {
case SDLK_UP: case SDLK_UP:
if (localCharacter) { if (localCharacter) {
localCharacter->motion.y += CHARACTER_WALKING_SPEED; localCharacter->motion.y += CHARACTER_WALKING_SPEED;
localCharacter->CorrectSprite();
SendPlayerUpdate(); SendPlayerUpdate();
} }
break; break;
@@ -239,6 +246,7 @@ void InWorld::KeyUp(SDL_KeyboardEvent const& key) {
case SDLK_DOWN: case SDLK_DOWN:
if (localCharacter) { if (localCharacter) {
localCharacter->motion.y -= CHARACTER_WALKING_SPEED; localCharacter->motion.y -= CHARACTER_WALKING_SPEED;
localCharacter->CorrectSprite();
SendPlayerUpdate(); SendPlayerUpdate();
} }
break; break;
@@ -297,7 +305,8 @@ void InWorld::HandleCharacterNew(CharacterPacket* const argPacket) {
character.CorrectSprite(); character.CorrectSprite();
//catch this client's player object //catch this client's player object
if (argPacket->characterIndex == characterIndex && !localCharacter) { if (argPacket->accountIndex == accountIndex && !localCharacter) {
characterIndex = argPacket->characterIndex;
localCharacter = &character; localCharacter = &character;
//setup the camera //setup the camera
+1 -8
View File
@@ -21,11 +21,6 @@
*/ */
#include "main_menu.hpp" #include "main_menu.hpp"
#include <iostream>
using std::cout;
using std::endl;
//------------------------- //-------------------------
//Public access members //Public access members
//------------------------- //-------------------------
@@ -60,9 +55,7 @@ MainMenu::MainMenu(ConfigUtility* const argConfig):
quitButton.SetText("Quit"); quitButton.SetText("Quit");
//debug //debug
cout << config["client.username"] << endl; //
cout << config["client.handle"] << endl;
cout << config["client.avatar"] << endl;
} }
MainMenu::~MainMenu() { MainMenu::~MainMenu() {
+1 -1
View File
@@ -3,7 +3,7 @@
#MKDIR=mkdir #MKDIR=mkdir
#RM=del /y #RM=del /y
CXXFLAGS+=-static-libgcc -static-libstdc++ -g CXXFLAGS+=-static-libgcc -static-libstdc++
export export
-8
View File
@@ -29,9 +29,6 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
using std::cout;
using std::endl;
//------------------------- //-------------------------
//public methods //public methods
//------------------------- //-------------------------
@@ -244,8 +241,6 @@ void ServerApplication::HandleBroadcastRequest(SerialPacket* const argPacket) {
} }
void ServerApplication::HandleJoinRequest(ClientPacket* const argPacket) { void ServerApplication::HandleJoinRequest(ClientPacket* const argPacket) {
cout << "Attempting connection: " << argPacket->username << endl;
//create the new client //create the new client
ClientData newClient; ClientData newClient;
newClient.address = argPacket->srcAddress; newClient.address = argPacket->srcAddress;
@@ -273,7 +268,6 @@ void ServerApplication::HandleJoinRequest(ClientPacket* const argPacket) {
} }
void ServerApplication::HandleDisconnect(ClientPacket* const argPacket) { void ServerApplication::HandleDisconnect(ClientPacket* const argPacket) {
cout << "Trying to disconnect account " << argPacket->accountIndex << endl;
//TODO: authenticate who is disconnecting/kicking //TODO: authenticate who is disconnecting/kicking
//forward to the specified client //forward to the specified client
@@ -287,10 +281,8 @@ void ServerApplication::HandleDisconnect(ClientPacket* const argPacket) {
characterMgr.UnloadCharacterIf([&](std::map<int, CharacterData>::iterator it) -> bool { characterMgr.UnloadCharacterIf([&](std::map<int, CharacterData>::iterator it) -> bool {
if (argPacket->accountIndex == it->second.owner) { if (argPacket->accountIndex == it->second.owner) {
PumpCharacterUnload(it->first); PumpCharacterUnload(it->first);
cout << "Deleting character " << it->first << endl;
return true; return true;
} }
cout << "Not deleting character " << it->first << endl;
return false; return false;
}); });
+1
View File
@@ -1,3 +1,4 @@
TODO: rename restart scene to cleanup scene
TODO: encapsulate the data structures TODO: encapsulate the data structures
TODO: Get the rooms working TODO: Get the rooms working