diff options
-rw-r--r-- | ChangeLog | 33 | ||||
-rwxr-xr-x | configure.ac | 72 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/engine.cpp | 13 | ||||
-rw-r--r-- | src/game.cpp | 184 | ||||
-rw-r--r-- | src/game.h | 1 | ||||
-rw-r--r-- | src/graphics.cpp | 6 | ||||
-rw-r--r-- | src/graphics.h | 4 | ||||
-rw-r--r-- | src/gui/popupmenu.cpp | 11 | ||||
-rw-r--r-- | src/gui/updatewindow.cpp | 6 | ||||
-rw-r--r-- | src/main.cpp | 2 | ||||
-rw-r--r-- | src/net/messagein.cpp | 2 | ||||
-rw-r--r-- | src/net/messageout.cpp | 6 | ||||
-rw-r--r-- | src/net/win2mac.cpp | 12 | ||||
-rw-r--r-- | src/net/win2mac.h | 1 | ||||
-rw-r--r-- | src/openglgraphics.h | 17 |
16 files changed, 144 insertions, 228 deletions
@@ -1,3 +1,21 @@ +2005-09-19 Bjørn Lindeijer <bjorn@lindeijer.nl> + + * configure.ac: Replaced custom function FIND_PATH with AC_PATH_PROG, + used for finding sdl-config. + * src/Makefile.am: Removed -lphysfs which should be added + automatically already. + * src/engine.cpp, src/game.h, src/game.cpp, src/openglgraphics.h, + src/gui/popupmenu.cpp, src/net/messagein.cpp, src/net/messageout.cpp, + src/net/win2mac.h, src/net/win2mac.cpp: Some cleanups. + * src/game.cpp: Actually show the overweight message, and only show it + once for each time weight goes above half the max weight (apparently + this code wasn't even tested once). + * src/graphics.cpp: Surfaces passed to SDL_BlitSurface shouldn't be + locked according to the manual. + * src/main.cpp: Minimal fps limit is now 10 fps. + * src/gui/updatewindow.cpp: Reverted change by Bertram that hardcoded + the updatehost value. + 2005-09-19 Eugenio Favalli <elvenprogrammer@gmail.com> * src/game.cpp, src/gui/trade.cpp, src/gui/updatewindow.cpp, @@ -16,15 +34,15 @@ last changes, and fixed the bug with npc lists I introduced earlier. * data/items.xml: Updated the defense value of fancy hat as pointed out by xand. - * src/game.cpp, src/gui/gui.cpp, src/gui/updatewindow.cpp, src/main.cpp, - src&resources/mapreader.cpp: Applyed biggeruniverse's patch to fix memory - leaks. - * src/game.cpp, src/main.cpp: Increased joypad tolerance which is safer + * src/game.cpp, src/gui/gui.cpp, src/gui/updatewindow.cpp, + src/main.cpp, src/resources/mapreader.cpp: Applied biggeruniverse's + patch to fix memory leaks. + * src/game.cpp, src/main.cpp: Increased joypad tolerance which is safer and simplifyed joypad state reset code. 2005-09-18 Duane Bailey <nayryeliab@gmail.com> - * game.cpp: added weight notice; now notifies person when they + * game.cpp: Added weight notice; now notifies person when they are carrying more then half their weight 2005-09-18 Yohann Ferreira <bertram@cegetel.net> @@ -70,8 +88,7 @@ 2005-09-17 Matthias Hartmann <hartmann.matthias@gmail.com> * src/engine.cpp: [TARGET] text over player - * src/game.cpp: PVP - * src/game.h: PVP + * src/game.cpp, src/game.h: PVP * src/gui/popupmenu.cpp: Added "attack" option to the popupmenu * src/net/protocol.cpp: findPlayer @@ -106,7 +123,7 @@ src/net/messageout.cpp, src/net/network.cpp, src/net/network.h, src/net/protocol.cpp, src/net/protocol.h: Completed transition to use MessageOut. - + 2005-09-17 Yohann Ferreira <bertram@cegetel.net> * src/game.cpp, src/gui/ministatus.cpp, src/gui/ministatus.h, diff --git a/configure.ac b/configure.ac index 4e9cffde..92366e0b 100755 --- a/configure.ac +++ b/configure.ac @@ -82,77 +82,23 @@ else with_opengl=no fi -# FIND_PATH(programm-name, variable-name, list of directories, -# if-not-found, test-parameter) -AC_DEFUN([FIND_PATH], -[ - AC_MSG_CHECKING([for $1]) - if test -n "$$2"; then - cv_path="$$2"; - else - cache=`echo $1 | sed 'y%./+-%__p_%'` - - AC_CACHE_VAL(cv_path_cache, - [ - cv_path="NONE" - dirs="$3" - save_IFS=$IFS - IFS=':' - for dir in $PATH; do - dirs="$dirs $dir" - done - IFS=$save_IFS - - for dir in $dirs; do - if test -x "$dir/$1"; then - if test -n "$5" - then - evalstr="$dir/$1 $5 2>&1 " - if eval $evalstr; then - cv_path="$dir/$1" - break - fi - else - cv_path="$dir/$1" - break - fi - fi - done - - eval "cv_path_$cache=$cv_path" - - ]) - - eval "cv_path=\"`echo '$cv_path_'$cache`\"" - - fi - - if test -z "$cv_path" || test "$cv_path" = NONE; then - AC_MSG_RESULT(not found) - $4 - else - AC_MSG_RESULT($cv_path) - $2=$cv_path - - fi -]) - -FIND_PATH(sdl-config, LIBSDL_CONFIG, [${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin], [ - AC_MSG_ERROR([Could not find libsdl anywhere, check http://www.sdl.org]) -]) +# Search for sdl-config +AC_PATH_PROG(LIBSDL_CONFIG, sdl-config) if test -n "$LIBSDL_CONFIG"; then LIBSDL_LIBS="`$LIBSDL_CONFIG --libs` -lSDL_image -lSDL_mixer -lpthread " LIBSDL_CFLAGS="`$LIBSDL_CONFIG --cflags`" + AC_SUBST(LIBSDL_LIBS) + AC_SUBST(LIBSDL_CFLAGS) - AC_DEFINE_UNQUOTED(HAVE_LIBSDL, 1, [Defines if your system has the LIBSDL library]) + AC_DEFINE_UNQUOTED(HAVE_LIBSDL, 1, + [Defines if your system has the LIBSDL library]) else - AC_DEFINE_UNQUOTED(HAVE_LIBSDL, 0, [Defines if your system has the LIBSDL library]) + AC_DEFINE_UNQUOTED(HAVE_LIBSDL, 0, + [Defines if your system has the LIBSDL library]) + AC_MSG_ERROR([Could not find sdl-config, check http://www.libsdl.org]) fi -AC_SUBST(LIBSDL_LIBS) -AC_SUBST(LIBSDL_CFLAGS) - AC_CONFIG_FILES([ Makefile src/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index ca96c88d..48ab6e02 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -182,5 +182,5 @@ INCLUDES = \ # the library search path. tmw_LDFLAGS = $(all_libraries) $(LIBSDL_RPATH) `pkg-config --libs libxml-2.0` tmw_CXXFLAGS = -Wall $(OPENGL_CFLAGS) $(LIBSDL_CFLAGS) `pkg-config --cflags libxml-2.0` $(CURL_CFLAGS) -tmw_LDADD = $(LIBSDL_LIBS) -lguichan_sdl -lguichan $(OPENGL_LIBS) -lphysfs $(CURL_LIBS) +tmw_LDADD = $(LIBSDL_LIBS) -lguichan_sdl -lguichan $(OPENGL_LIBS) $(CURL_LIBS) tmw_TARGET = tmw diff --git a/src/engine.cpp b/src/engine.cpp index 8194e00b..0209fbbc 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -467,16 +467,17 @@ void Engine::draw() being->drawSpeech(graphics); } - if (autoTarget) { + if (autoTarget) + { if (autoTarget->getType() == Being::PLAYER) { graphics->drawText("[TARGET]", - autoTarget->text_x+15, - autoTarget->text_y-60, + autoTarget->text_x + 15, + autoTarget->text_y - 60, gcn::Graphics::CENTER); - - } else { - + } + else + { graphics->drawText("[TARGET]", autoTarget->text_x + 60, autoTarget->text_y, diff --git a/src/game.cpp b/src/game.cpp index dac21cb8..0748d65b 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -354,9 +354,9 @@ bool saveScreenshot(SDL_Surface *screenshot) do { screenshotCount++; filename.str(""); - #ifdef __USE_UNIX98 - filename << PHYSFS_getUserDir() << "/"; - #endif +#ifdef __USE_UNIX98 + filename << PHYSFS_getUserDir() << "/"; +#endif filename << "TMW_Screenshot_" << screenshotCount << ".png"; testExists.open(filename.str().c_str(), std::ios::in); found = !testExists.is_open(); @@ -405,7 +405,7 @@ void game() do_parse(); flush(); } - + do_exit(); } @@ -431,7 +431,7 @@ void do_input() // TODO: Only <= 6 buttons joypads are allowed bool joy[10]; memset(joy, 0, 10 * sizeof(bool)); - + // Get the state of the joypad axis/buttons if (joypad != NULL) { @@ -548,12 +548,14 @@ void do_input() // Picking up items on the floor case SDLK_g: case SDLK_z: - if (!chatWindow->isFocused()) { + if (!chatWindow->isFocused()) + { unsigned short x = player_node->x; unsigned short y = player_node->y; int id = find_floor_item_by_cor(x, y); - // If none below the player, try the tile in front of the player + // If none below the player, try the tile in front of + // the player if (!id) { switch (player_node->direction) { @@ -719,21 +721,8 @@ void do_input() { switch (target->getType()) { - // Player default: attack - case Being::PLAYER: - if (target != player_node) - { - autoTarget = target; - attack(target); - /*MessageOut outMsg; - outMsg.writeShort(CMSG_TRADE_REQUEST); - outMsg.writeLong(target->getId()); - tradePartnerName = target->getName();*/ - } - break; - - // NPC default: talk case Being::NPC: + // NPC default: talk if (!current_npc) { MessageOut outMsg; @@ -744,21 +733,21 @@ void do_input() } break; - // Monster default: attack case Being::MONSTER: + case Being::PLAYER: + // Monster and player default: attack /** * TODO: Move player to mouse click position before * attack the monster (maybe using follow mode). */ if (target->action != Being::MONSTER_DEAD && - player_node->action == Being::STAND) + player_node->action == Being::STAND && + target != player_node) { - attack(target); // Autotarget by default with mouse - //if (keys[SDLK_LSHIFT]) - //{ autoTarget = target; - //} + + attack(target); } break; @@ -917,8 +906,11 @@ void do_input() tiledMap = engine->getCurrentMap(); // Allow keyboard control to interrupt an existing path - if ((xDirection != 0 || yDirection != 0) && player_node->action == Being::WALK) + if ((xDirection != 0 || yDirection != 0) && + player_node->action == Being::WALK) + { player_node->setDestination(x, y); + } if (player_node->action != Being::WALK) { @@ -954,7 +946,8 @@ void do_input() if (keys[SDLK_LCTRL] || keys[SDLK_RCTRL] || joy[JOY_BTN0]) { Being *monster = attack(x, y, player_node->direction); - if (monster == NULL && autoTarget != NULL && monster != player_node) + if (monster == NULL && autoTarget != NULL && + monster != player_node) { attack(autoTarget); } @@ -1540,79 +1533,59 @@ void do_parse() break; case SMSG_PLAYER_STAT_UPDATE_1: - switch (msg.readShort()) { - //case 0x0000: - // player_node->speed = msg.readLong(); - // break; - case 0x0005: - player_info->hp = msg.readLong(); - break; - case 0x0006: - player_info->maxHp = msg.readLong(); - break; - case 0x0007: - player_info->mp = msg.readLong(); - break; - case 0x0008: - player_info->maxMp = msg.readLong(); - break; - case 0x000b: - player_info->lvl = msg.readLong(); - break; - case 0x000c: - player_info->skillPoint = msg.readLong(); - skillDialog->setPoints(player_info->skillPoint); - break; - case 0x0018: - player_info->totalWeight = msg.readLong(); - if (player_info->totalWeight >= player_info->maxWeight) - { - weightNotice = new OkDialog("Message", - "You are carrying more then half your weight. You are unable to regain health.", - &weightNoticeListener); - weightNotice->releaseModalFocus(); - } - break; - case 0x0019: - player_info->maxWeight = msg.readLong(); - break; - case 0x0037: - player_info->jobLvl = msg.readLong(); - break; - case 0x0009: - player_info->statsPointsToAttribute = msg.readLong(); - break; - case 0x0029: - player_info->ATK = msg.readLong(); - break; - case 0x002b: - player_info->MATK = msg.readLong(); - break; - case 0x002d: - player_info->DEF = msg.readLong(); - break; - case 0x002f: - player_info->MDEF = msg.readLong(); - break; - case 0x0031: - player_info->HIT = msg.readLong(); - break; - case 0x0032: - player_info->FLEE = msg.readLong(); - break; - case 0x0035: - player_node->aspd = msg.readLong(); - break; - } + short type = msg.readShort(); + long value = msg.readLong(); - if (player_info->hp == 0 && deathNotice == NULL) - { - deathNotice = new OkDialog("Message", - "You're now dead, press ok to restart", - &deathNoticeListener); - deathNotice->releaseModalFocus(); - player_node->action = Being::DEAD; + switch (type) + { + //case 0x0000: + // player_node->speed = msg.readLong(); + // break; + case 0x0005: player_info->hp = value; break; + case 0x0006: player_info->maxHp = value; break; + case 0x0007: player_info->mp = value; break; + case 0x0008: player_info->maxMp = value; break; + case 0x000b: player_info->lvl = value; break; + case 0x000c: + player_info->skillPoint = value; + skillDialog->setPoints(player_info->skillPoint); + break; + case 0x0018: + if (value >= player_info->maxWeight / 2 && + player_info->totalWeight < + player_info->maxWeight / 2) + { + weightNotice = new OkDialog("Message", + "You are carrying more then half your " + "weight. You are unable to regain " + "health.", + &weightNoticeListener); + } + player_info->totalWeight = value; + break; + case 0x0019: player_info->maxWeight = value; break; + case 0x0037: player_info->jobLvl = value; break; + case 0x0009: + player_info->statsPointsToAttribute = value; + break; + case 0x0029: player_info->ATK = value; break; + case 0x002b: player_info->MATK = value; break; + case 0x002d: player_info->DEF = value; break; + case 0x002f: player_info->MDEF = value; break; + case 0x0031: player_info->HIT = value; break; + case 0x0032: player_info->FLEE = value; break; + case 0x0035: player_node->aspd = value; break; + } + + if (player_info->hp == 0 && deathNotice == NULL) + { + deathNotice = new OkDialog("Message", + "You're now dead, press ok to restart", + &deathNoticeListener); + deathNotice->releaseModalFocus(); + player_node->action = Being::DEAD; + } } break; @@ -1633,14 +1606,13 @@ void do_parse() { Being *srcBeing = findNode(msg.readLong()); Being *dstBeing = findNode(msg.readLong()); -// msg.readLong(); // server tick -// msg.readLong(); // src speed -// msg.readLong(); // dst speed - msg.skip(12); + msg.readLong(); // server tick + msg.readLong(); // src speed + msg.readLong(); // dst speed short param1 = msg.readShort(); - msg.skip(2); // param 2 + msg.readShort(); // param 2 char type = msg.readByte(); - msg.skip(2); // param 3 + msg.readShort(); // param 3 switch (type) { @@ -39,7 +39,6 @@ extern std::string tradePartnerName; extern int fps, frame, current_npc; extern volatile int tick_time; extern int server_tick; -extern Being* autoTarget; extern bool displayPathToMouse; extern unsigned short startX, startY; diff --git a/src/graphics.cpp b/src/graphics.cpp index 33f25468..74b71888 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -256,13 +256,7 @@ SDL_Surface* Graphics::getScreenshot() SDL_Surface *screenshot = SDL_CreateRGBSurface(SDL_SWSURFACE, mScreen->w, mScreen->h, 24, rmask, gmask, bmask, amask); - if (SDL_MUSTLOCK(mScreen)) { - SDL_LockSurface(mScreen); - } SDL_BlitSurface(mScreen, NULL, screenshot, NULL); - if (SDL_MUSTLOCK(mScreen)) { - SDL_UnlockSurface(mScreen); - } return screenshot; } diff --git a/src/graphics.h b/src/graphics.h index a0749795..6a69a7ef 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -120,8 +120,8 @@ class Graphics : public gcn::SDLGraphics { int getHeight(); /** - * takes a screenshot and returns it as SDL surface - */ + * Takes a screenshot and returns it as SDL surface. + */ virtual SDL_Surface* getScreenshot(); protected: diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 7f72702e..feb287eb 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -46,6 +46,7 @@ #include "../resources/iteminfo.h" #include "../resources/itemmanager.h" +extern Being* autoTarget; PopupMenu::PopupMenu(): Window() @@ -148,15 +149,14 @@ void PopupMenu::handleLink(const std::string& link) //tradePartner << "Trade: You and " << being->name<< ""; tradePartnerName = being->getName(); } - + // Attack action else if ((link == "attack") && being && being->getType() == Being::PLAYER) { - - autoTarget = being; + autoTarget = being; attack(being); - } - + } + /* // Follow Player action else if (link == "follow") @@ -215,7 +215,6 @@ void PopupMenu::handleLink(const std::string& link) { // do nothing for now, I need to write // a window for the description first - ; } // Unknown actions diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index fe410ece..cd26aca9 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -85,11 +85,7 @@ UpdaterWindow::UpdaterWindow(): mCancelButton->requestFocus(); setLocationRelativeTo(getParent()); - // That commented line causes problems if the client had a false value for an update host - // in its config file. - // The update host, unlike the home dir, isn't dynamically set at the start of the client. - // mUpdateHost = config.getValue("updatehost", "themanaworld.org/files"); - mUpdateHost = "themanaworld.org/files"; + mUpdateHost = config.getValue("updatehost", "themanaworld.org/files"); mBasePath = config.getValue("homeDir", "."); // Try to download the updates list diff --git a/src/main.cpp b/src/main.cpp index ad60bbaf..79e2a767 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -290,7 +290,7 @@ void init_engine() int fpsLimit = (int)config.getValue("fpslimit", 0); if (fpsLimit) { - if (fpsLimit < 20) fpsLimit = 20; + if (fpsLimit < 10) fpsLimit = 10; if (fpsLimit > 200) fpsLimit = 200; SDL_AddTimer(1000 / fpsLimit, nextFrame, NULL); } diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 9ea6f12e..c599a453 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -24,7 +24,7 @@ #include "messagein.h" #include <cassert> -#include <SDL_net.h> +#include <SDL.h> #if SDL_BYTEORDER == SDL_BIG_ENDIAN #include "win2mac.h" #endif diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp index e7928a4d..77819b63 100644 --- a/src/net/messageout.cpp +++ b/src/net/messageout.cpp @@ -24,8 +24,10 @@ #include "messageout.h" #include <string> -#include <SDL_net.h> +#include <SDL.h> +#if SDL_BYTEORDER == SDL_BIG_ENDIAN #include "win2mac.h" +#endif #include "network.h" #include "packet.h" @@ -73,7 +75,6 @@ void MessageOut::writeShort(short value) #else (*(short *)(mData + mPos)) = value; #endif - //SDLNet_Write16(value, &mData[mPos]); mPos += sizeof(short); out_size += sizeof(short); } @@ -86,7 +87,6 @@ void MessageOut::writeLong(long value) #else (*(long *)(mData + mPos)) = value; #endif - //SDLNet_Write32(value, &mData[mPos]); mPos += sizeof(long); out_size += sizeof(long); } diff --git a/src/net/win2mac.cpp b/src/net/win2mac.cpp index d6da2cf2..020b808b 100644 --- a/src/net/win2mac.cpp +++ b/src/net/win2mac.cpp @@ -1,7 +1,5 @@ #include "win2mac.h" -#define SWAP( a, b ) { char c; c=a; a=b; b=c; } - UInt32 DR_SwapFourBytes(UInt32 dw) { UInt32 tmp; @@ -19,13 +17,3 @@ UInt16 DR_SwapTwoBytes(UInt16 w) tmp = ((w & 0xFF00) >> 0x08) | (tmp << 0x08); return(tmp); } - -char* SwapChar(char charlist[]) -{ - for (int i = 0; i < 24 / 2; i++) - { - SWAP(charlist[i], charlist[24 - i]); - } - - return charlist; -} diff --git a/src/net/win2mac.h b/src/net/win2mac.h index 29102fae..d0a99dad 100644 --- a/src/net/win2mac.h +++ b/src/net/win2mac.h @@ -8,6 +8,5 @@ UInt32 DR_SwapFourBytes(UInt32 dw); UInt16 DR_SwapTwoBytes(UInt16 w); -char* SwapChar(char charlist[]); #endif diff --git a/src/openglgraphics.h b/src/openglgraphics.h index cd99e6a6..c61ae66c 100644 --- a/src/openglgraphics.h +++ b/src/openglgraphics.h @@ -35,7 +35,10 @@ class OpenGLGraphics : public Graphics bool setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel); - bool drawImage(Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height); + bool drawImage(Image *image, + int srcX, int srcY, + int dstX, int dstY, + int width, int height); void updateScreen(); @@ -47,8 +50,10 @@ class OpenGLGraphics : public Graphics void setColor(const gcn::Color &color); - void drawImage(const gcn::Image* image, int srcX, int srcY, - int dstX, int dstY, int width, int height); + void drawImage(const gcn::Image* image, + int srcX, int srcY, + int dstX, int dstY, + int width, int height); void drawPoint(int x, int y); @@ -63,14 +68,14 @@ class OpenGLGraphics : public Graphics void setTargetPlane(int width, int height); /** - * takes a screenshot and returns it as SDL surface - */ + * Takes a screenshot and returns it as SDL surface. + */ SDL_Surface* getScreenshot(); protected: void setTexturingAndBlending(bool enable); void drawTexedQuad(int x, int y, int w, int h, - float texX1, float texY1, float texX2, float texY2); + float texX1, float texY1, float texX2, float texY2); private: bool mAlpha, mTexture; |