summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--src/game.cpp10
-rw-r--r--src/game.h5
-rw-r--r--src/gui/char_select.cpp7
-rw-r--r--src/main.cpp7
-rw-r--r--src/main.h1
-rw-r--r--src/net/charserverhandler.cpp5
7 files changed, 28 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index d2a98990..0c5bc4dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,10 @@
-2007-02-23 Rogier Polak <rogier.l.a.polak@gmail.com>
+2007-02-25 Rogier Polak <rogier.l.a.polak@gmail.com>
+
+ * src/main.h, src/main.cpp, src/game.h, src/game.cpp,
+ src/gui/char_select.cpp, src/net/charserverhandler.cpp: Fixed small
+ issue concerning SDL timers, removed a useless variable.
+
+2007-02-23 Rogier Polak <rogier.l.a.polak@gmail.com>
* src/gui/char_select.h, src/gui/char_select.cpp,
src/gui/unregisterdialog.h, src/gui/unregisterdialog.cpp,
diff --git a/src/game.cpp b/src/game.cpp
index bc81add5..9eaa0693 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -228,7 +228,8 @@ Game::Game():
mNpcHandler(new NPCHandler()),
mPlayerHandler(new PlayerHandler()),
mSkillHandler(new SkillHandler()),
- mTradeHandler(new TradeHandler())
+ mTradeHandler(new TradeHandler()),
+ mLogicCounterId(0), mSecondsCounterId(0)
{
done = false;
@@ -240,8 +241,8 @@ Game::Game():
// Initialize timers
tick_time = 0;
- SDL_AddTimer(10, nextTick, NULL); // Logic counter
- SDL_AddTimer(1000, nextSecond, NULL); // Seconds counter
+ mLogicCounterId = SDL_AddTimer(10, nextTick, NULL); //Logic counter
+ mSecondsCounterId = SDL_AddTimer(1000, nextSecond, NULL);//Seconds counter
// Initialize frame limiting
config.addListener("fpslimit", this);
@@ -285,6 +286,9 @@ Game::~Game()
beingManager = NULL;
floorItemManager = NULL;
joystick = NULL;
+
+ SDL_RemoveTimer(mLogicCounterId);
+ SDL_RemoveTimer(mSecondsCounterId);
}
bool saveScreenshot(SDL_Surface *screenshot)
diff --git a/src/game.h b/src/game.h
index 19a6054a..408b933b 100644
--- a/src/game.h
+++ b/src/game.h
@@ -27,6 +27,8 @@
#include <iosfwd>
#include <memory>
+#include "SDL.h"
+
#include "configlistener.h"
#define SPEECH_TIME 80
@@ -68,6 +70,9 @@ class Game : public ConfigListener
MessageHandlerPtr mPlayerHandler;
MessageHandlerPtr mSkillHandler;
MessageHandlerPtr mTradeHandler;
+
+ SDL_TimerID mLogicCounterId;
+ SDL_TimerID mSecondsCounterId;
};
/**
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index 5e329598..d5a28bec 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -134,7 +134,8 @@ CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo,
void CharSelectDialog::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "ok" && n_character > 0)
+ // The pointers are set to NULL if there is no character stored
+ if (event.getId() == "ok" && (mCharInfo->getEntry()))
{
// Start game
mNewCharButton->setEnabled(false);
@@ -153,7 +154,9 @@ void CharSelectDialog::action(const gcn::ActionEvent &event)
}
else if (event.getId() == "new")
{
- if (n_character < MAX_SLOT + 1)
+ //TODO: search the first free slot, and start CharCreateDialog
+ // maybe add that search to the constructor
+ if (!(mCharInfo->getEntry()))
{
// Start new character dialog
mCharInfo->lock();
diff --git a/src/main.cpp b/src/main.cpp
index e953d456..7fa996af 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -88,9 +88,7 @@
#include "utils/dtor.h"
#include "utils/tostring.h"
-// Account infos
-char n_character;
-std::string token;
+std::string token; //used to store magic_token
Graphics *graphics;
@@ -441,7 +439,6 @@ void accountLogin(LoginData *loginData)
Net::registerHandler(&loginHandler);
- charInfo.clear();
charServerHandler.setCharInfo(&charInfo);
Net::registerHandler(&charServerHandler);
@@ -467,7 +464,6 @@ void accountRegister(LoginData *loginData)
Net::registerHandler(&loginHandler);
- charInfo.clear();
charServerHandler.setCharInfo(&charInfo);
Net::registerHandler(&charServerHandler);
@@ -571,7 +567,6 @@ void reconnectAccount(const std::string& passToken)
{
Net::registerHandler(&loginHandler);
- charInfo.clear();
charServerHandler.setCharInfo(&charInfo);
Net::registerHandler(&charServerHandler);
diff --git a/src/main.h b/src/main.h
index 057e781f..4dd93ae8 100644
--- a/src/main.h
+++ b/src/main.h
@@ -115,7 +115,6 @@ const short defaultMusicVolume = 60;
const std::string defaultAccountServerName = "animesites.de";
const short defaultAccountServerPort = 9601;
-extern char n_character;
extern std::string token;
extern unsigned char state;
extern std::string errorMessage;
diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp
index f715b434..848b97fb 100644
--- a/src/net/charserverhandler.cpp
+++ b/src/net/charserverhandler.cpp
@@ -71,7 +71,6 @@ CharServerHandler::handleMessage(MessageIn &msg)
delete mCharInfo->getEntry();
mCharInfo->setEntry(0);
mCharInfo->unlock();
- n_character--;
new OkDialog("Info", "Player deleted");
}
// Character deletion failed
@@ -100,7 +99,6 @@ CharServerHandler::handleMessage(MessageIn &msg)
mCharInfo->unlock();
mCharInfo->select(slot);
mCharInfo->setEntry(tempPlayer);
- n_character++;
break;
case APMSG_CHAR_SELECT_RESPONSE:
@@ -184,6 +182,7 @@ CharServerHandler::handleCharSelectResponse(MessageIn &msg)
player_node = mCharInfo->getEntry();
mCharInfo->unlock();
mCharInfo->select(0);
+
do {
LocalPlayer *tmp = mCharInfo->getEntry();
if (tmp != player_node)
@@ -191,6 +190,8 @@ CharServerHandler::handleCharSelectResponse(MessageIn &msg)
mCharInfo->next();
} while (mCharInfo->getPos());
+ mCharInfo->clear(); //player_node will be deleted by ~Game
+
state = STATE_CONNECT_GAME;
}
}