summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog23
-rw-r--r--configure.ac24
-rwxr-xr-xrunserv.sh10
-rw-r--r--src/Makefile.am18
-rw-r--r--src/client.cpp707
-rw-r--r--src/defines.h9
-rw-r--r--src/game-server/gamehandler.cpp4
-rw-r--r--src/game-server/mapcomposite.cpp74
-rw-r--r--src/game-server/mapcomposite.hpp26
-rw-r--r--src/game-server/mapmanager.cpp2
-rw-r--r--src/game-server/state.cpp173
-rw-r--r--src/game-server/state.hpp17
-rw-r--r--src/game-server/testing.cpp37
-rw-r--r--src/game-server/trigger.cpp55
-rw-r--r--src/game-server/trigger.hpp62
-rw-r--r--src/object.h96
-rw-r--r--src/point.h32
-rw-r--r--src/tests/Makefile.am47
-rw-r--r--src/tests/testaccount.cpp202
-rw-r--r--src/tests/testaccount.h116
-rw-r--r--src/tests/testcipher.cpp170
-rw-r--r--src/tests/testcipher.h115
-rw-r--r--src/tests/testdataprovider.cpp351
-rw-r--r--src/tests/testdataprovider.h156
-rw-r--r--src/tests/testrecordset.cpp320
-rw-r--r--src/tests/testrecordset.h215
-rw-r--r--src/tests/testsmain.cpp70
-rw-r--r--src/tests/teststorage.cpp746
-rw-r--r--src/tests/teststorage.h243
-rw-r--r--tmwserv.cbp478
-rw-r--r--tmwserv.dev919
31 files changed, 422 insertions, 5095 deletions
diff --git a/ChangeLog b/ChangeLog
index 8da539e4..9e34e53d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,26 @@
+2007-01-02 Guillaume Melquiond <guillaume.melquiond@gmail.com>
+
+ * tmwserv.cbp, tmwserv.dev, runserv.sh: Removed obsolete project files
+ and shell script.
+ * configure.ac, src/Makefile.am, src/tests, src/client.cpp: Removed
+ obsolete tests and text client.
+ * src/game-server/mapcomposite.hpp, src/game-server/mapcomposite.cpp,
+ src/point.h: Removed implicit radius for checking range of Point. Added
+ a Rectangle class. Added support for rectangles in MapComposite.
+ * src/object.h, src/defines.h, src/game-server/mapcomposite.hpp,
+ src/game-server/mapcomposite.cpp, src/game-server/state.hpp,
+ src/game-server/state.cpp: Put an ancestor for Object that are not
+ visible to clients. Added simple accessors for object types.
+ * src/game-server/mapmanager.cpp: Prevented loading unactive maps.
+ * src/game-server/trigger.hpp, src/game-server/trigger.cpp: Added a
+ trigger mechanism and a warp action.
+ * src/game-server/testing.cpp: Added some hardcoded game objects for
+ testing purpose.
+
2006-12-31 Philipp Sehmisch <tmw@crushnet.org>
- * accountserver.cbp, gameserver.cbp, runsrv.bat: Added Code::Blocks project
- files and windows start script.
+ * accountserver.cbp, gameserver.cbp, runsrv.bat: Added Code::Blocks
+ project files and windows start script.
2006-12-31 Guillaume Melquiond <guillaume.melquiond@gmail.com>
diff --git a/configure.ac b/configure.ac
index 5dc70cfb..9a885651 100644
--- a/configure.ac
+++ b/configure.ac
@@ -139,23 +139,6 @@ elif test "$with_scripting_engine" != "no"; then
fi
-# Checks for the unit tests.
-AC_ARG_ENABLE(
- [unit-tests],
- AS_HELP_STRING([--enable-unit-tests], [compile the unit tests]),
- [if test "$enableval" = "yes"; then
- enable_unit_tests="$enableval"
-
- # use cppunit-config to check the libcppunit.
- # CPPUNIT_CFLAGS and CPPUNIT_LIBS are set by AC_CHECK_LIB_TMW.
- AC_CHECK_LIB_TMW([cppunit], [1.10.2])
- else
- enable_unit_tests="no"
- fi],
- [enable_unit_tests="no"]
-)
-
-
AM_CONDITIONAL(BUILD_MYSQL, test "$with_storage_backend" = "mysql")
AM_CONDITIONAL(BUILD_POSTGRESQL, test "$with_storage_backend" = "postgresql")
AM_CONDITIONAL(BUILD_SQLITE, test "$with_storage_backend" = "sqlite")
@@ -163,12 +146,7 @@ AM_CONDITIONAL(BUILD_SQLITE, test "$with_storage_backend" = "sqlite")
AM_CONDITIONAL(BUILD_RUBY, test "$with_scripting_engine" = "ruby")
AM_CONDITIONAL(BUILD_SQUIRREL, test "$with_scripting_engine" = "squirrel")
-AM_CONDITIONAL(UNIT_TESTS_YES, test "$enable_unit_tests" = "yes")
-
-
-AC_CONFIG_FILES([Makefile
- src/Makefile
- src/tests/Makefile])
+AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
diff --git a/runserv.sh b/runserv.sh
deleted file mode 100755
index d7b8b51e..00000000
--- a/runserv.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-ulimit -c 100000000
-while [ true ] ; do
- src/tmwserv --verbosity 2
-
- for CORE in `ls core*` ; do
- gdb -batch src/tmwserv $CORE > backtrace-`date +%Y%m%d-%H%M%S`
- mv $CORE usedcore
- done
-done
diff --git a/src/Makefile.am b/src/Makefile.am
index 99434fa9..7b4e27ee 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,15 +2,7 @@
AUTOMAKE_OPTIONS = subdir-objects
-bin_PROGRAMS = tmwclient tmwserv-account tmwserv-game
-
-tmwclient_SOURCES = \
- client.cpp \
- defines.h \
- net/messagein.hpp \
- net/messagein.cpp \
- net/messageout.hpp \
- net/messageout.cpp
+bin_PROGRAMS = tmwserv-account tmwserv-game
tmwserv_account_SOURCES = \
account-server/main-account.cpp \
@@ -118,6 +110,9 @@ tmwserv_game_SOURCES = \
game-server/mapmanager.cpp \
game-server/state.hpp \
game-server/state.cpp \
+ game-server/testing.cpp \
+ game-server/trigger.hpp \
+ game-server/trigger.cpp \
net/connection.hpp \
net/connection.cpp \
net/connectionhandler.hpp \
@@ -174,8 +169,3 @@ bindings_wrap.cpp: bindings.i
tmwserv_game_SOURCES += \
bindings_wrap.cpp
endif
-
-
-# do not remove the 'dot', it is a hint for Automake.
-# it causes a prefix ordering of directories.
-SUBDIRS = . tests
diff --git a/src/client.cpp b/src/client.cpp
deleted file mode 100644
index ef516fdb..00000000
--- a/src/client.cpp
+++ /dev/null
@@ -1,707 +0,0 @@
-/*
- * The Mana World Server
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or any later version.
- *
- * The Mana World is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with The Mana World; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#include <iostream>
-#include <enet/enet.h>
-
-#include "defines.h"
-#include "net/messagein.hpp"
-#include "net/messageout.hpp"
-
-#if defined WIN32
-#include "../testclient_private.h"
-#define PACKAGE_VERSION PRODUCT_VERSION
-#endif
-
-void parsePacket(char *data, int recvLength);
-
-ENetHost *client;
-ENetAddress addressAccount, addressGame, addressChat;
-ENetPeer *peerAccount, *peerGame, *peerChat;
-std::string token;
-bool connected = false;
-
-int main(int argc, char *argv[])
-{
-
-#if (defined __USE_UNIX98 || defined __FreeBSD__)
-#include "../config.h"
-#endif
- std::cout << "The Mana World Test Client v" << PACKAGE_VERSION << std::endl;
-
- if (enet_initialize () != 0)
- {
- printf("An error occurred while initializing ENet.\n");
- return EXIT_FAILURE;
- }
-
- atexit(enet_deinitialize);
-
- client = enet_host_create(NULL /* create a client host */,
- 3 /* allows 3 outgoing connection */,
- 57600 / 8 /* 56K modem with 56 Kbps downstream bandwidth */,
- 14400 / 8 /* 56K modem with 14 Kbps upstream bandwidth */);
-
- if (client == NULL)
- {
- printf("An error occurred while trying to create an ENet client host.\n");
- exit (EXIT_FAILURE);
- }
-
- /* Connect to localhost:9601. */
- enet_address_set_host(&addressAccount, "localhost");
- addressAccount.port = 9601;
-
- /* Initiate the connection, allocating one channel. */
- peerAccount = enet_host_connect(client, &addressAccount, 1);
-
- if (peerAccount == NULL)
- {
- printf("No available peers for initiating an ENet connection.\n");
- exit (EXIT_FAILURE);
- }
-
- ENetEvent event;
- bool exit = true;
- char line[256] = "";
-
- printf("Starting client...\n");
-
- /* Wait up to 1000 milliseconds for an event. */
- do {
- if (connected) {
- int answer = -1;
- std::cout << std::endl;
- std::cout << "0) Quit 9) Select Character" << std::endl;
- std::cout << "1) Register 10) Delete Character" << std::endl;
- std::cout << "2) Unregister" << std::endl;
- std::cout << "3) Login 12) Move Character" << std::endl;
- std::cout << "4) Logout 13) Say Around" << std::endl;
- std::cout << "5) Change Password 14) Equip Item" << std::endl;
- std::cout << "6) Change Email 15) Ruby Expression" << std::endl;
- std::cout << "7) Get Email 16) Enter Game Server" << std::endl;
- std::cout << "8) Create character 17) Enter Chat Server" << std::endl;
- std::cout << "Choose your option: ";
- std::cin >> answer;
- std::cin.getline(line, 256); // skip the remaining of the line
-
- MessageOut msg;
- int msgDestination = 0; // account server
-
- switch (answer) {
- case 0:
- // Disconnection
- if (connected) {
- enet_peer_disconnect(&client->peers[0], 0);
- }
- exit = true;
- break;
-
- case 1:
- // Register
- msg.writeShort(PAMSG_REGISTER);
- // We send the client version
- msg.writeLong(0);
- std::cout << "Account name: ";
- std::cin >> line;
- msg.writeString(line);
- std::cout << "Password: ";
- std::cin >> line;
- msg.writeString(line);
- std::cout << "Email address: ";
- std::cin >> line;
- msg.writeString(line);
- break;
-
- case 2:
- // Unregister (deleting an account)
- msg.writeShort(PAMSG_UNREGISTER);
- std::cout << "Account name: ";
- std::cin >> line;
- msg.writeString(line);
- std::cout << "Password: ";
- std::cin >> line;
- msg.writeString(line);
- break;
-
- case 3:
- // Login
- msg.writeShort(PAMSG_LOGIN);
- // We send the client version
- msg.writeLong(0);
- std::cout << "Account name: ";
- std::cin >> line;
- msg.writeString(line);
- std::cout << "Password: ";
- std::cin >> line;
- msg.writeString(line);
- break;
-
- case 4:
- // Logout
- msg.writeShort(PAMSG_LOGOUT);
- std::cout << "Logout" << std::endl;
- break;
-
- case 5:
- {
- // Change Password
- msg.writeShort(PAMSG_PASSWORD_CHANGE);
- std::cout << "Old Password: ";
- std::cin >> line;
- msg.writeString(line);
- std::cout << "New Password: ";
- std::cin >> line;
- msg.writeString(line);
- std::string line2;
- std::cout << "Retype new Password: ";
- std::cin >> line2;
- if (line != line2)
- {
- std::cout << "Error: Password mismatch." << std::endl;
- goto process_enet;
- }
- } break;
-
- case 6:
- // Change Email
- msg.writeShort(PAMSG_EMAIL_CHANGE);
- std::cout << "New Email: ";
- std::cin >> line;
- msg.writeString(line);
- break;
-
- case 7:
- // Get current Account's Email value
- msg.writeShort(PAMSG_EMAIL_GET);
- break;
-
- case 8:
- {
- // Create character
- msg.writeShort(PAMSG_CHAR_CREATE);
- std::cout << "Name: ";
- std::cin >> line;
- msg.writeString(line);
-
- std::cout << "Hair Style ID (0 - " << MAX_HAIRSTYLE_VALUE << "): ";
- std::cin >> line;
- msg.writeByte(atoi(line));
-
- std::cout << "Hair Color ID (0 - " << MAX_HAIRCOLOR_VALUE << "): ";
- std::cin >> line;
- msg.writeByte(atoi(line));
-
- std::cout << "Gender ID (0 - " << MAX_GENDER_VALUE << "): ";
- std::cin >> line;
- msg.writeByte(atoi(line));
-
- std::cout << "Strength: ";
- std::cin >> line;
- msg.writeShort(atoi(line));
-
- std::cout << "Agility: ";
- std::cin >> line;
- msg.writeShort(atoi(line));
-
- std::cout << "Vitality: ";
- std::cin >> line;
- msg.writeShort(atoi(line));
-
- std::cout << "Intelligence: ";
- std::cin >> line;
- msg.writeShort(atoi(line));
-
- std::cout << "Dexterity: ";
- std::cin >> line;
- msg.writeShort(atoi(line));
-
- std::cout << "Luck: ";
- std::cin >> line;
- msg.writeShort(atoi(line));
- } break;
-
- case 9:
- {
- // Select character
- msg.writeShort(PAMSG_CHAR_SELECT);
- std::cout << "Character ID: ";
- std::cin >> line;
- msg.writeByte(atoi(line));
- } break;
-
- case 10:
- {
- // Delete character
- msg.writeShort(PAMSG_CHAR_DELETE);
- std::cout << "Character ID: ";
- std::cin >> line;
- msg.writeByte(atoi(line));
- } break;
-
- case 12:
- {
- // Move character
- long x, y;
- std::cout << "X: ";
- std::cin >> x;
- std::cout << "Y: ";
- std::cin >> y;
-
- msg.writeShort(PGMSG_WALK);
- msg.writeShort(x);
- msg.writeShort(y);
-
- msgDestination = 1;
- } break;
-
- case 13:
- {
- // Chat
- msg.writeShort(PGMSG_SAY);
- std::cout << "Say: ";
- std::cin.getline(line, 256);
- line[255] = '\0';
- msg.writeString(line);
-
- msgDestination = 1;
- } break;
-
- case 14:
- {
- // Equip
- unsigned int itemId;
- unsigned int slot;
- std::cout << "Item ID: ";
- std::cin >> itemId;
- std::cout << "Slot: ";
- std::cin >> slot;
- msg.writeShort(PGMSG_EQUIP);
- msg.writeLong(itemId);
- msg.writeByte(slot);
-
- msgDestination = 1;
- } break;
-
- case 15:
- {
- std::cout << "Expr: ";
- std::cin >> line;
- msg.writeShort(0x800);
- msg.writeString(line);
- } break;
-
- case 16:
- {
- // enter game server
- msg.writeShort(PGMSG_CONNECT);
- msg.writeString(token, 32);
- msgDestination = 1;
- } break;
-
- case 17:
- {
- // enter chat server
- msg.writeShort(PCMSG_CONNECT);
- msg.writeString(token, 32);
- msgDestination = 2;
- } break;
-
- default:
- goto process_enet;
- } // end switch
-
- // Send prepared message
- if (!exit && connected) {
- ENetPacket *packet = enet_packet_create(
- msg.getData(), msg.getLength(),
- ENET_PACKET_FLAG_RELIABLE);
- ENetPeer *peer = peerAccount;
- if (msgDestination == 1) peer = peerGame;
- else if (msgDestination == 2) peer = peerChat;
- if (peer) {
- // Send the packet to the peer over channel id 0.
- enet_peer_send(peer, 0, packet);
- } else
- std::cout << "Peer " << msgDestination << " is not connected. "
- "Cannot send packet." << std::endl;
- } // end if
- } // end if
-
- process_enet:
- while (enet_host_service(client, &event, 2000)) {
- switch (event.type) {
- case ENET_EVENT_TYPE_CONNECT:
- printf("Connected to server\n");
- connected = true;
- exit = false;
- break;
-
- case ENET_EVENT_TYPE_RECEIVE:
- std::cout << "A packet of length "
- << event.packet->dataLength
- << " was received from "
- << event.peer->address.host
- << std::endl;
-
- parsePacket((char *)event.packet->data,
- event.packet->dataLength);
-
- // Clean up the packet now that we're done using it.
- enet_packet_destroy(event.packet);
- break;
-
- case ENET_EVENT_TYPE_DISCONNECT:
- printf("Disconnected.\n");
- connected = false;
- exit = true;
- break;
-
- default:
- //printf("Unhandled enet event.\n");
- break;
- } // end switch
- } // end while
- } while (!exit);
-
- if (connected) {
- // The disconnection attempt didn't succeed yet. Force disconnection.
- enet_peer_reset(&client->peers[0]);
- }
-
- enet_host_destroy(client);
-
- return 0;
-}
-
-void parsePacket(char *data, int recvLength) {
- // Response handling
- // Transforming it into a MessageIn object
- if (recvLength >= 2) {
- MessageIn msg(data, recvLength);
-
- switch (msg.getId()) {
- case APMSG_REGISTER_RESPONSE:
- // Register
- switch (msg.readByte()) {
- case ERRMSG_OK:
- std::cout << "Account registered." << std::endl;
- break;
- case ERRMSG_INVALID_ARGUMENT:
- std::cout << "Account registering: Invalid username, password, or email." << std::endl;
- break;
- case REGISTER_INVALID_VERSION:
- std::cout << "Account registering: Invalid version." << std::endl;
- break;
- case REGISTER_EXISTS_USERNAME:
- std::cout << "Account registering: Username already exists." << std::endl;
- break;
- case REGISTER_EXISTS_EMAIL:
- std::cout << "Account registering: Email already exists." << std::endl;
- break;
- default:
- std::cout << "Account registering: Unknown error." << std::endl;
- break;
- }
- break;
-
- case APMSG_UNREGISTER_RESPONSE:
- // Register
- switch (msg.readByte()) {
- case ERRMSG_OK:
- std::cout << "Account unregistered." << std::endl;
- break;
- case ERRMSG_INVALID_ARGUMENT:
- std::cout << "Account unregistering: Invalid username or password." << std::endl;
- break;
- default:
- std::cout << "Account unregistering: Unknown error." << std::endl;
- break;
- }
- break;
-
- case APMSG_LOGIN_RESPONSE:
- // Register
- switch (msg.readByte()) {
- case ERRMSG_OK:
- std::cout << "Login successful." << std::endl;
- break;
- case ERRMSG_INVALID_ARGUMENT:
- std::cout << "Login: Invalid username or password." << std::endl;
- break;
- case LOGIN_INVALID_VERSION:
- std::cout << "Login: Invalid Version." << std::endl;
- break;
- case ERRMSG_FAILURE:
- std::cout << "Login: Already logged with another account." << std::endl;
- break;
- default:
- std::cout << "Login: Unknown error." << std::endl;
- break;
- }
- break;
-
- case APMSG_LOGOUT_RESPONSE:
- {
- switch (msg.readByte()) {
- case ERRMSG_OK:
- std::cout << "Logout..." << std::endl;
- break;
- case ERRMSG_NO_LOGIN:
- std::cout << "Logout: Unsuccessful." << std::endl;
- break;
- default:
- std::cout << "Logout: Unknown error." << std::endl;
- }
- } break;
-
- case APMSG_PASSWORD_CHANGE_RESPONSE:
- {
- switch (msg.readByte()) {
- case ERRMSG_OK:
- std::cout << "Password correctly changed." << std::endl;
- break;
- case ERRMSG_NO_LOGIN:
- std::cout << "Password change: Not logged in." << std::endl;
- break;
- case ERRMSG_INVALID_ARGUMENT:
- std::cout << "Password change: New password is invalid." << std::endl;
- break;
- case ERRMSG_FAILURE:
- std::cout << "Password change: Old password is invalid." << std::endl;
- break;
- default:
- std::cout << "Password change: Unknown error." << std::endl;
- break;
- }
- } break;
-
- case APMSG_EMAIL_CHANGE_RESPONSE:
- {
- switch (msg.readByte()) {
- case ERRMSG_OK:
- std::cout << "Email correctly changed." << std::endl;
- break;
- case ERRMSG_NO_LOGIN:
- std::cout << "Email change: Not logged in." << std::endl;
- break;
- case EMAILCHG_EXISTS_EMAIL:
- std::cout << "Email change: Email already exists." << std::endl;
- break;
- case ERRMSG_INVALID_ARGUMENT:
- std::cout << "Email change: New Email is invalid." << std::endl;
- break;
- default:
- std::cout << "Email change: Unknown error." << std::endl;
- break;
- }
- } break;
-
- case APMSG_EMAIL_GET_RESPONSE:
- {
- switch (msg.readByte()) {
- case ERRMSG_OK:
- std::cout << "Current Email: " << msg.readString() << std::endl;
- break;
- case ERRMSG_NO_LOGIN:
- std::cout << "Get Email: Not logged in." << std::endl;
- break;
- default:
- std::cout << "Get Email: Unknown error." << std::endl;
- break;
- }
- } break;
-
- case APMSG_CHAR_CREATE_RESPONSE:
- {
- switch (msg.readByte()) {
- case ERRMSG_OK:
- std::cout << "Character Created successfully." << std::endl;
- break;
- case CREATE_EXISTS_NAME:
- std::cout << "Character Creation: Character's name already exists."
- << std::endl;
- break;
- case ERRMSG_NO_LOGIN:
- std::cout << "Character Creation: Not logged in." << std::endl;
- break;
- case CREATE_TOO_MUCH_CHARACTERS:
- std::cout << "Character Creation: Too much characters." << std::endl;
- break;
- case CREATE_INVALID_HAIRSTYLE:
- std::cout << "Character Creation: Invalid Hair Style Value." << std::endl;
- break;
- case CREATE_INVALID_HAIRCOLOR:
- std::cout << "Character Creation: Invalid Hair Color Value." << std::endl;
- break;
- case CREATE_INVALID_GENDER:
- std::cout << "Character Creation: Invalid Gender Value." << std::endl;
- break;
- case CREATE_RAW_STATS_EQUAL_TO_ZERO:
- std::cout << "Character Creation: a Statistic is equal to zero." << std::endl;
- break;
- case CREATE_RAW_STATS_INVALID_DIFF:
- std::cout << "Character Creation: Statistics disproportionned." << std::endl;
- break;
- case CREATE_RAW_STATS_TOO_HIGH:
- std::cout << "Character Creation: Statistics too high for level 1." << std::endl;
- break;
- case CREATE_RAW_STATS_TOO_LOW:
- std::cout << "Character Creation: Statistics too low for level 1." << std::endl;
- break;
- default:
- std::cout << "Character Creation: Unknown error." << std::endl;
- break;
- }
- } break;
-
- case APMSG_CHAR_DELETE_RESPONSE:
- {
- switch (msg.readByte()) {
- case ERRMSG_OK:
- std::cout << "Character deleted." << std::endl;
- break;
- case ERRMSG_INVALID_ARGUMENT:
- std::cout << "Character Deletion: Character's ID doesn't exist."
- << std::endl;
- break;
- case ERRMSG_NO_LOGIN:
- std::cout << "Character Deletion: Not logged in." << std::endl;
- break;
- default:
- std::cout << "Character Deletion: Unknown error." << std::endl;
- break;
- }
- } break;
-
- case APMSG_CHAR_SELECT_RESPONSE:
- {
- switch (msg.readByte()) {
- case ERRMSG_OK:
- {
- std::cout << "Character selected successfully." << std::endl;
- std::cout << "Current Map: " << msg.readString() << std::endl;
- std::string server = msg.readString();
- enet_address_set_host(&addressGame, server.c_str());
- addressGame.port = msg.readShort();
- peerGame = enet_host_connect(client, &addressGame, 1);
- std::cout << "Connecting to " << server << ':' << addressGame.port;
- server = msg.readString();
- enet_address_set_host(&addressChat, server.c_str());
- addressChat.port = msg.readShort();
- peerChat = enet_host_connect(client, &addressChat, 1);
- token = msg.readString(32);
- connected = false;
- std::cout << " and to " << server << ':' << addressChat.port << std::endl;
- } break;
- case ERRMSG_INVALID_ARGUMENT:
- std::cout << "Character Selection: invalid ID."
- << std::endl;
- break;
- case ERRMSG_NO_LOGIN:
- std::cout << "Character Selection: Not logged in." << std::endl;
- break;
- default:
- std::cout << "Character Selection: Unknown error." << std::endl;
- break;
- }
- } break;
-
- case APMSG_CHAR_INFO:
- {
- std::cout << "Information on character " << int(msg.readByte()) << std::endl;
- std::cout << " Name: " << msg.readString() << std::endl;
- std::cout << " Gender: " << int(msg.readByte()) << ", ";
- std::cout << "Hair Style: " << int(msg.readByte()) << ", ";
- std::cout << "Hair Color: " << int(msg.readByte()) << std::endl;
- std::cout << " Level: " << int(msg.readByte()) << ", ";
- std::cout << "Money: " << int(msg.readShort()) << std::endl;
- std::cout << " Strength: " << int(msg.readShort()) << ", ";
- std::cout << "Agility: " << int(msg.readShort()) << ", ";
- std::cout << "Vitality: " << int(msg.readShort()) << std::endl;
- std::cout << " Intelligence: " << int(msg.readShort()) << ", ";
- std::cout << "Dexterity: " << int(msg.readShort()) << ", ";
- std::cout << "Luck: " << int(msg.readShort()) << std::endl;
- //std::cout << " Current Map: " << msg.readString() << " (X:";
- //std::cout << int(msg.readShort()) << ", Y:";
- //std::cout << int(msg.readShort()) << ")" << std::endl;
- } break;
-
- case GPMSG_SAY:
- {
- std::string who = msg.readString();
- std::cout << who << " says around:" << std::endl
- << msg.readString() << std::endl;
- } break;
-
- case GPMSG_BEING_LEAVE:
- {
- switch (msg.readByte()) {
- case OBJECT_PLAYER:
- std::cout << "Player " << msg.readLong() << " left map." << std::endl;
- break;
- default:
- std::cout << "Unknown being left map." << std::endl;
- }
- } break;
-
- case GPMSG_BEING_ENTER:
- {
- switch (msg.readByte()) {
- case OBJECT_PLAYER:
- std::cout << "Player " << msg.readLong() << " entered map" << std::endl;
- std::cout << " name: " << msg.readString() << std::endl;
- std::cout << " hair style: " << (int)msg.readByte() << std::endl;
- std::cout << " hair color: " << (int)msg.readByte() << std::endl;
- std::cout << " gender: " << (int)msg.readByte() << std::endl;
- break;
- default:
- std::cout << "Unknown being entered map." << std::endl;
- }
- } break;
-
- case GPMSG_BEINGS_MOVE:
- {
- int nb = (recvLength - 2) / (1*4 + 4*2);
- std::cout << "Beings are moving:" << std::endl;
- for(; nb > 0; --nb) {
- int id = msg.readLong();
- int cx = msg.readShort(), cy = msg.readShort();
- int dx = msg.readShort(), dy = msg.readShort();
- std::cout << " ID " << id << " at ("
- << cx << ", " << cy << ") toward ("
- << dx << ", " << dy << ")." << std::endl;
- }
- } break;
-
- case XXMSG_INVALID:
- std::cout << "The server does not understand our message." << std::endl;
- break;
- default:
- std::cout << "Unknown message received. Id: " << msg.getId() << "." << std::endl;
- break;
- } // end switch MessageId
-
- } // end if recLength > 2 (MessageLength > 2)
-
-}
-
diff --git a/src/defines.h b/src/defines.h
index b5a44898..fc8c8705 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -247,15 +247,6 @@ enum {
CHAT_EVENT_LEAVING_PLAYER
};
-// Object type enumeration
-enum {
- OBJECT_ITEM = 0, // A simple item
- OBJECT_ACTOR, // An item that toggle map/quest actions (doors, switchs, ...) and can speak (map panels).
- OBJECT_NPC, // Non-Playable-Character is an actor capable of movement and maybe actions
- OBJECT_MONSTER, // A monster (moving actor with AI. Should be able to toggle map/quest actions, too)
- OBJECT_PLAYER // A normal being
-};
-
// Moving object flags
enum {
// Payload contains the current position.
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index c8e22350..56b9533c 100644
--- a/src/game-server/gamehandler.cpp
+++ b/src/game-server/gamehandler.cpp
@@ -78,7 +78,7 @@ static void linkCharacter(GameClient *computer, Player *ch)
computer->character = ch;
computer->status = CLIENT_CONNECTED;
ch->setClient(computer);
- gameState->insertObject(ch);
+ gameState->insert(ch);
MessageOut result;
result.writeShort(GPMSG_CONNECT_RESPONSE);
result.writeByte(ERRMSG_OK);
@@ -130,7 +130,7 @@ void GameHandler::computerDisconnected(NetComputer *computer)
}
if (Player *ch = static_cast< GameClient * >(computer)->character)
{
- gameState->removeObject(ch);
+ gameState->remove(ch);
delete ch;
}
delete computer;
diff --git a/src/game-server/mapcomposite.cpp b/src/game-server/mapcomposite.cpp
index b877a775..8b7ef9d7 100644
--- a/src/game-server/mapcomposite.cpp
+++ b/src/game-server/mapcomposite.cpp
@@ -364,6 +364,21 @@ void MapComposite::fillRegion(MapRegion &r, Point const &p, int radius) const
}
}
+void MapComposite::fillRegion(MapRegion &r, Rectangle const &p) const
+{
+ int ax = p.x / zoneDiam,
+ ay = p.y / zoneDiam,
+ bx = std::max((p.x + p.w) / zoneDiam, mapWidth - 1),
+ by = std::max((p.y + p.h) / zoneDiam, mapHeight - 1);
+ for (int y = ay; y <= by; ++y)
+ {
+ for (int x = ax; x <= bx; ++x)
+ {
+ addZone(r, x + y * mapWidth);
+ }
+ }
+}
+
ZoneIterator MapComposite::getAroundObjectIterator(Object *obj, int radius) const
{
MapRegion r;
@@ -371,6 +386,13 @@ ZoneIterator MapComposite::getAroundObjectIterator(Object *obj, int radius) cons
return ZoneIterator(r, this);
}
+ZoneIterator MapComposite::getInsideRectangleIterator(Rectangle const &p) const
+{
+ MapRegion r;
+ fillRegion(r, p);
+ return ZoneIterator(r, this);
+}
+
ZoneIterator MapComposite::getAroundPlayerIterator(Player *obj, int radius) const
{
MapRegion r1;
@@ -396,42 +418,45 @@ ZoneIterator MapComposite::getAroundPlayerIterator(Player *obj, int radius) cons
return ZoneIterator(r2, this);
}
-bool MapComposite::insert(Object *obj)
+bool MapComposite::insert(Thing *ptr)
{
- Point const &pos = obj->getPosition();
- zones[(pos.x / zoneDiam) + (pos.y / zoneDiam) * mapWidth].insert(obj);
-
- int type = obj->getType();
- if (type == OBJECT_MONSTER || type == OBJECT_PLAYER || type == OBJECT_NPC)
+ if (ptr->isVisible())
{
- if (!allocate(static_cast< MovingObject * >(obj)))
+ if (ptr->canMove() && !allocate(static_cast< MovingObject * >(ptr)))
{
return false;
}
+
+ Object *obj = static_cast< Object * >(ptr);
+ Point const &pos = obj->getPosition();
+ zones[(pos.x / zoneDiam) + (pos.y / zoneDiam) * mapWidth].insert(obj);
}
- objects.push_back(obj);
+ things.push_back(ptr);
return true;
}
-void MapComposite::remove(Object *obj)
+void MapComposite::remove(Thing *ptr)
{
- Point const &pos = obj->getPosition();
- zones[(pos.x / zoneDiam) + (pos.y / zoneDiam) * mapWidth].remove(obj);
-
- int type = obj->getType();
- if (type == OBJECT_MONSTER || type == OBJECT_PLAYER || type == OBJECT_NPC)
+ if (ptr->isVisible())
{
- deallocate(static_cast< MovingObject * >(obj));
+ Object *obj = static_cast< Object * >(ptr);
+ Point const &pos = obj->getPosition();
+ zones[(pos.x / zoneDiam) + (pos.y / zoneDiam) * mapWidth].remove(obj);
+
+ if (ptr->canMove())
+ {
+ deallocate(static_cast< MovingObject * >(ptr));
+ }
}
- for (Objects::iterator o = objects.begin(),
- o_end = objects.end(); o != o_end; ++o)
+ for (std::vector< Thing * >::iterator i = things.begin(),
+ i_end = things.end(); i != i_end; ++i)
{
- if (*o == obj)
+ if (*i == ptr)
{
- *o = *(o_end - 1);
- objects.pop_back();
+ *i = *(i_end - 1);
+ things.pop_back();
return;
}
}
@@ -446,15 +471,14 @@ void MapComposite::update()
}
// Cannot use a WholeMap iterator as objects will change zones under its feet.
- for (Objects::iterator o = objects.begin(),
- o_end = objects.end(); o != o_end; ++o)
+ for (std::vector< Thing * >::iterator i = things.begin(),
+ i_end = things.end(); i != i_end; ++i)
{
- int type = (*o)->getType();
- if (type != OBJECT_PLAYER && type != OBJECT_MONSTER && type != OBJECT_NPC)
+ if (!(*i)->canMove())
{
continue;
}
- MovingObject *obj = static_cast< MovingObject * >(*o);
+ MovingObject *obj = static_cast< MovingObject * >(*i);
Point const &pos1 = obj->getOldPosition(),
&pos2 = obj->getPosition();
diff --git a/src/game-server/mapcomposite.hpp b/src/game-server/mapcomposite.hpp
index 84599d39..0623f602 100644
--- a/src/game-server/mapcomposite.hpp
+++ b/src/game-server/mapcomposite.hpp
@@ -152,14 +152,14 @@ class MapComposite {
{ return map; }
/**
- * Inserts an object on the map and sets its public ID.
+ * Inserts an object on the map. Sets its public ID if relevant.
*/
- bool insert(Object *);
+ bool insert(Thing *);
/**
* Removes an object from the map.
*/
- void remove(Object *);
+ void remove(Thing *);
/**
* Updates zones of every moving beings.
@@ -178,6 +178,11 @@ class MapComposite {
{ return ZoneIterator(MapRegion(), this); }
/**
+ * Gets an iterator on the objects inside a given rectangle.
+ */
+ ZoneIterator getInsideRectangleIterator(Rectangle const &) const;
+
+ /**
* Gets an iterator on the objects around a given object.
*/
ZoneIterator getAroundObjectIterator(Object *, int radius) const;
@@ -189,10 +194,10 @@ class MapComposite {
ZoneIterator getAroundPlayerIterator(Player *, int radius) const;
/**
- * Gets all the objects on the map.
+ * Gets everything related to the map.
*/
- Objects const &getObjects() const
- { return objects; }
+ std::vector< Thing * > const &getEverything() const
+ { return things; }
private:
MapComposite(MapComposite const &);
@@ -212,12 +217,17 @@ class MapComposite {
*/
void fillRegion(MapRegion &, Point const &, int) const;
+ /**
+ * Fills a region of zones inside a rectangle.
+ */
+ void fillRegion(MapRegion &, Rectangle const &) const;
+
Map *map; /**< Actual map. */
/**
- * Objects (items, players, monsters, etc) located on the map.
+ * Things (items, players, monsters, etc) located on the map.
*/
- Objects objects;
+ std::vector< Thing * > things;
/**
* Buckets of MovingObjects located on the map, referenced by ID.
diff --git a/src/game-server/mapmanager.cpp b/src/game-server/mapmanager.cpp
index f4bb33bd..1cef6281 100644
--- a/src/game-server/mapmanager.cpp
+++ b/src/game-server/mapmanager.cpp
@@ -91,7 +91,7 @@ MapManager::~MapManager()
Map *MapManager::getMap(int mapId)
{
Maps::iterator i = maps.find(mapId);
- assert(i != maps.end());
+ assert(i != maps.end() && i->second.isActive);
Map *&map = i->second.map;
if (!map)
{
diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp
index f7c12d98..7e78857e 100644
--- a/src/game-server/state.cpp
+++ b/src/game-server/state.cpp
@@ -35,21 +35,6 @@
#include "net/messageout.hpp"
#include "utils/logger.h"
-State::State()
-{
- // Create 10 maggots for testing purposes
- for (int i = 0; i < 10; i++)
- {
- Being *being = new Controlled(OBJECT_MONSTER);
- being->setSpeed(150);
- being->setMapId(1);
- Point pos = { 720, 900 };
- being->setPosition(pos);
- DelayedEvent e = { EVENT_INSERT };
- enqueueEvent(being, e);
- }
-}
-
State::~State()
{
for (Maps::iterator i = maps.begin(), i_end = maps.end(); i != i_end; ++i)
@@ -61,7 +46,9 @@ State::~State()
void State::updateMap(MapComposite *map)
{
// 1. update object status.
- for (ObjectIterator i(map->getWholeMapIterator()); i; ++i)
+ std::vector< Thing * > const &things = map->getEverything();
+ for (std::vector< Thing * >::const_iterator i = things.begin(),
+ i_end = things.end(); i != i_end; ++i)
{
(*i)->update();
}
@@ -82,32 +69,6 @@ void State::updateMap(MapComposite *map)
(*i)->move();
}
map->update();
-
- // 4. Just for fun. Should be replaced by a real trigger system.
- for (MovingObjectIterator i(map->getWholeMapIterator()); i; ++i)
- {
- Object *o = *i;
- if (o->getType() != OBJECT_PLAYER) continue;
- Point pos = o->getPosition();
- int x = pos.x / 32, y = pos.y / 32;
- int m = 0;
- switch (o->getMapId())
- {
- case 1:
- if (x >= 56 && x <= 60 && y == 12)
- { m = 3; x = 44; y = 80; }
- break;
- case 3:
- if (x >= 42 && x <= 46 && y == 88)
- { m = 1; x = 58; y = 17; }
- break;
- }
- if (m != 0)
- {
- DelayedEvent e = { EVENT_WARP, m, x * 32 + 16, y * 32 + 16 };
- enqueueEvent(o, e);
- }
- }
}
void State::informPlayer(MapComposite *map, Player *p)
@@ -125,33 +86,35 @@ void State::informPlayer(MapComposite *map, Player *p)
int otype = o->getType();
int oid = o->getPublicID(), oflags = o->getUpdateFlags();
int flags = 0;
+ bool willBeInRange = ppos.inRangeOf(opos, AROUND_AREA);
- // Send attack messages.
- if ((oflags & ATTACK) && oid != pid && ppos.inRangeOf(opos))
+ if (willBeInRange)
{
- MessageOut AttackMsg(GPMSG_BEING_ATTACK);
- AttackMsg.writeShort(oid);
- gameHandler->sendTo(p, AttackMsg);
- }
+ // Send attack messages.
+ if ((oflags & ATTACK) && oid != pid)
+ {
+ MessageOut AttackMsg(GPMSG_BEING_ATTACK);
+ AttackMsg.writeShort(oid);
+ gameHandler->sendTo(p, AttackMsg);
+ }
- // Send damage messages.
- if (otype == OBJECT_PLAYER || otype == OBJECT_MONSTER)
- {
- Being *victim = static_cast< Being * >(o);
- Hits const &hits = victim->getHitsTaken();
- for (Hits::const_iterator j = hits.begin(),
- j_end = hits.end(); j != j_end; ++j)
+ // Send damage messages.
+ if (o->canFight())
{
- damageMsg.writeShort(oid);
- damageMsg.writeShort(*j);
+ Being *victim = static_cast< Being * >(o);
+ Hits const &hits = victim->getHitsTaken();
+ for (Hits::const_iterator j = hits.begin(),
+ j_end = hits.end(); j != j_end; ++j)
+ {
+ damageMsg.writeShort(oid);
+ damageMsg.writeShort(*j);
+ }
}
}
- /* Check whether this player and this moving object were around
- the last time and whether they will be around the next time. */
- bool wereInRange = pold.inRangeOf(oold) &&
+ // Check if this player and this moving object were around.
+ bool wereInRange = pold.inRangeOf(oold, AROUND_AREA) &&
!((pflags | oflags) & NEW_ON_MAP);
- bool willBeInRange = ppos.inRangeOf(opos);
// Send enter/leaver messages.
if (!wereInRange)
@@ -256,8 +219,7 @@ void State::update()
{
Object *o = *i;
o->clearUpdateFlags();
- int type = o->getType();
- if (type == OBJECT_PLAYER || type == OBJECT_MONSTER)
+ if (o->canFight())
{
static_cast< Being * >(o)->clearHitsTaken();
}
@@ -274,7 +236,7 @@ void State::update()
{
case EVENT_REMOVE:
{
- removeObject(o);
+ remove(o);
if (o->getType() == OBJECT_PLAYER)
{
gameHandler->kill(static_cast< Player * >(o));
@@ -284,18 +246,18 @@ void State::update()
case EVENT_INSERT:
{
- insertObject(o);
+ insert(o);
} break;
case EVENT_WARP:
{
- removeObject(o);
+ remove(o);
o->setMapId(e.map);
Point pos = { e.x, e.y };
o->setPosition(pos);
if (mapManager->isActive(e.map))
{
- insertObject(o);
+ insert(o);
}
else
{
@@ -313,56 +275,57 @@ void State::update()
delayedEvents.clear();
}
-void State::insertObject(Object *objectPtr)
+void State::insert(Thing *ptr)
{
- int mapId = objectPtr->getMapId();
+ int mapId = ptr->getMapId();
MapComposite *map = loadMap(mapId);
- if (!map || !map->insert(objectPtr))
+ if (!map || !map->insert(ptr))
{
- // TODO: Deal with failure to place Object on the map.
+ // TODO: Deal with failure to place Thing on the map.
return;
}
- objectPtr->raiseUpdateFlags(NEW_ON_MAP);
- if (objectPtr->getType() != OBJECT_PLAYER) return;
- Player *playerPtr = static_cast< Player * >(objectPtr);
-
- /* Since the player doesn't know yet where on the world he is after
- * connecting to the map server, we send him an initial change map message.
- */
- MessageOut mapChangeMessage(GPMSG_PLAYER_MAP_CHANGE);
- mapChangeMessage.writeString(mapManager->getMapName(mapId));
- Point pos = playerPtr->getPosition();
- mapChangeMessage.writeShort(pos.x);
- mapChangeMessage.writeShort(pos.y);
- mapChangeMessage.writeByte(0);
- gameHandler->sendTo(playerPtr, mapChangeMessage);
+
+ if (ptr->isVisible())
+ {
+ Object *obj = static_cast< Object * >(ptr);
+ obj->raiseUpdateFlags(NEW_ON_MAP);
+ if (obj->getType() != OBJECT_PLAYER) return;
+
+ /* Since the player doesn't know yet where on the world he is after
+ connecting to the map server, we send him an initial change map message. */
+ MessageOut mapChangeMessage(GPMSG_PLAYER_MAP_CHANGE);
+ mapChangeMessage.writeString(mapManager->getMapName(mapId));
+ Point pos = obj->getPosition();
+ mapChangeMessage.writeShort(pos.x);
+ mapChangeMessage.writeShort(pos.y);
+ gameHandler->sendTo(static_cast< Player * >(obj), mapChangeMessage);
+ }
}
-void State::removeObject(Object *objectPtr)
+void State::remove(Thing *ptr)
{
- int mapId = objectPtr->getMapId();
+ int mapId = ptr->getMapId();
Maps::iterator m = maps.find(mapId);
- if (m == maps.end()) return;
+ assert(m != maps.end());
MapComposite *map = m->second;
- int type = objectPtr->getType();
- if (type == OBJECT_MONSTER || type == OBJECT_PLAYER || type == OBJECT_NPC)
+ if (ptr->canMove())
{
- MovingObject *obj = static_cast< MovingObject * >(objectPtr);
+ MovingObject *obj = static_cast< MovingObject * >(ptr);
MessageOut msg(GPMSG_BEING_LEAVE);
msg.writeShort(obj->getPublicID());
Point objectPos = obj->getPosition();
for (PlayerIterator p(map->getAroundObjectIterator(obj, AROUND_AREA)); p; ++p)
{
- if (*p != obj && objectPos.inRangeOf((*p)->getPosition()))
+ if (*p != obj && objectPos.inRangeOf((*p)->getPosition(), AROUND_AREA))
{
gameHandler->sendTo(*p, msg);
}
}
}
- map->remove(objectPtr);
+ map->remove(ptr);
}
void State::enqueueEvent(Object *ptr, DelayedEvent const &e)
@@ -376,6 +339,13 @@ void State::enqueueEvent(Object *ptr, DelayedEvent const &e)
}
}
+MapComposite *State::getMap(int map)
+{
+ Maps::iterator m = maps.find(map);
+ assert(m != maps.end());
+ return m->second;
+}
+
MapComposite *State::loadMap(int mapId)
{
Maps::iterator m = maps.find(mapId);
@@ -386,30 +356,25 @@ MapComposite *State::loadMap(int mapId)
maps[mapId] = tmp;
// will need to load extra map related resources here also
+ extern void testingMap(int);
+ testingMap(mapId);
return tmp;
}
void State::sayAround(Object *obj, std::string text)
{
- unsigned short id = 65535;
- int type = obj->getType();
- if (type == OBJECT_PLAYER || type == OBJECT_NPC || type == OBJECT_MONSTER)
- {
- id = static_cast< MovingObject * >(obj)->getPublicID();
- }
MessageOut msg(GPMSG_SAY);
- msg.writeShort(id);
+ msg.writeShort(!obj->canMove() ? 65535 :
+ static_cast< MovingObject * >(obj)->getPublicID());
msg.writeString(text);
- Maps::iterator m = maps.find(obj->getMapId());
- if (m == maps.end()) return;
- MapComposite *map = m->second;
+ MapComposite *map = getMap(obj->getMapId());
Point speakerPosition = obj->getPosition();
for (PlayerIterator i(map->getAroundObjectIterator(obj, AROUND_AREA)); i; ++i)
{
- if (speakerPosition.inRangeOf((*i)->getPosition()))
+ if (speakerPosition.inRangeOf((*i)->getPosition(), AROUND_AREA))
{
gameHandler->sendTo(*i, msg);
}
diff --git a/src/game-server/state.hpp b/src/game-server/state.hpp
index d759da88..44c71600 100644
--- a/src/game-server/state.hpp
+++ b/src/game-server/state.hpp
@@ -28,7 +28,9 @@
#include <string>
class MapComposite;
+class Thing;
class Object;
+class Player;
enum
{
@@ -71,8 +73,12 @@ class State
*/
void informPlayer(MapComposite *, Player *);
+ /**
+ * Loads map into game world.
+ */
+ MapComposite *loadMap(int mapId);
+
public:
- State();
~State();
/**
@@ -81,19 +87,18 @@ class State
void update();
/**
- * Loads map into game world.
+ * Gets a composite map.
*/
- MapComposite *loadMap(int mapId);
-
+ MapComposite *getMap(int map);
/**
* Inserts an object on the map.
*/
- void insertObject(Object *);
+ void insert(Thing *);
/**
* Removes an object from the map.
*/
- void removeObject(Object *);
+ void remove(Thing *);
/**
* Enqueues an event. It will be executed at end of update.
diff --git a/src/game-server/testing.cpp b/src/game-server/testing.cpp
new file mode 100644
index 00000000..e580694d
--- /dev/null
+++ b/src/game-server/testing.cpp
@@ -0,0 +1,37 @@
+/* This file is for testing purpose only. It hardcodes some events related
+ to the game. It should be removed once all the related managers have been
+ implemented. There are no headers for this file on purpose. */
+
+#include "controller.h"
+#include "game-server/state.hpp"
+#include "game-server/trigger.hpp"
+
+static Rectangle rectA = { 56 * 32, 12 * 32, 5 * 32, 32 };
+static WarpAction warpA(3, 44 * 32 + 16, 80 * 32 + 16);
+static Rectangle rectB = { 42 * 32, 88 * 32, 5 * 32, 32 };
+static WarpAction warpB(1, 58 * 32 + 16, 17 * 32 + 16);
+
+void testingMap(int id)
+{
+ switch (id)
+ {
+ case 1:
+ {
+ gameState->insert(new TriggerArea(1, rectA, &warpA));
+ for (int i = 0; i < 10; i++)
+ {
+ Being *being = new Controlled(OBJECT_MONSTER);
+ being->setSpeed(150);
+ being->setMapId(1);
+ Point pos = { 720, 900 };
+ being->setPosition(pos);
+ gameState->insert(being);
+ }
+ } break;
+
+ case 3:
+ {
+ gameState->insert(new TriggerArea(3, rectB, &warpB));
+ } break;
+ }
+}
diff --git a/src/game-server/trigger.cpp b/src/game-server/trigger.cpp
new file mode 100644
index 00000000..22a25697
--- /dev/null
+++ b/src/game-server/trigger.cpp
@@ -0,0 +1,55 @@
+/*
+ * The Mana World Server
+ * Copyright 2006 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#include "player.h"
+#include "game-server/mapcomposite.hpp"
+#include "game-server/state.hpp"
+#include "game-server/trigger.hpp"
+
+void WarpAction::process(Object *obj)
+{
+ if (obj->getType() == OBJECT_PLAYER)
+ {
+ DelayedEvent e = { EVENT_WARP, mMap, mX, mY };
+ gameState->enqueueEvent(obj, e);
+ }
+}
+
+TriggerArea::TriggerArea(int map, Rectangle const &r, TriggerAction *ptr)
+ : Thing(OBJECT_OTHER), mZone(r), mAction(ptr)
+{
+ setMapId(map);
+}
+
+void TriggerArea::update()
+{
+ MapComposite *map = gameState->getMap(getMapId());
+
+ for (MovingObjectIterator i(map->getInsideRectangleIterator(mZone)); i; ++i)
+ {
+ if (mZone.contains((*i)->getPosition()))
+ {
+ mAction->process(*i);
+ }
+ }
+}
diff --git a/src/game-server/trigger.hpp b/src/game-server/trigger.hpp
new file mode 100644
index 00000000..a3149812
--- /dev/null
+++ b/src/game-server/trigger.hpp
@@ -0,0 +1,62 @@
+/*
+ * The Mana World Server
+ * Copyright 2006 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#ifndef _TMWSERV_TRIGGER
+#define _TMWSERV_TRIGGER
+
+#include "object.h"
+
+class TriggerAction
+{
+ public:
+ virtual ~TriggerAction() {}
+ virtual void process(Object *) = 0;
+};
+
+class WarpAction: public TriggerAction
+{
+ public:
+ WarpAction(int m, int x, int y)
+ : mMap(m), mX(x), mY(y) {}
+
+ virtual void process(Object *);
+
+ private:
+ unsigned short mMap, mX, mY;
+};
+
+class TriggerArea: public Thing
+{
+ public:
+ /**
+ * Creates a rectangular trigger for a given map.
+ */
+ TriggerArea(int, Rectangle const &, TriggerAction *);
+ virtual void update();
+
+ private:
+ Rectangle mZone;
+ TriggerAction *mAction;
+};
+
+#endif
diff --git a/src/object.h b/src/object.h
index b3511bf8..4ad8c0be 100644
--- a/src/object.h
+++ b/src/object.h
@@ -28,6 +28,16 @@
#include "point.h"
+// Object type enumeration
+enum {
+ OBJECT_ITEM = 0, // A simple item
+ OBJECT_ACTOR, // An item that toggle map/quest actions (doors, switchs, ...) and can speak (map panels).
+ OBJECT_NPC, // Non-Playable-Character is an actor capable of movement and maybe actions
+ OBJECT_MONSTER, // A monster (moving actor with AI. Should be able to toggle map/quest actions, too)
+ OBJECT_PLAYER, // A normal being
+ OBJECT_OTHER // Server-only object
+};
+
class MapComposite;
enum
@@ -37,59 +47,59 @@ enum
ATTACK = 4
};
-
/**
- * Generic in-game object definition.
* Base class for in-game objects.
*/
-class Object
+class Thing
{
public:
/**
* Constructor.
*/
- Object(int type)
- : mType(type),
- mUpdateFlags(0)
+ Thing(int type)
+ : mType(type)
{}
/**
* Empty virtual destructor.
*/
- virtual ~Object() {}
+ virtual ~Thing() {}
/**
- * Get type.
+ * Gets type.
*
* @return the type.
*/
- unsigned int getType() const
+ int getType() const
{ return mType; }
/**
- * Sets the coordinates.
- *
- * @param p the coordinates.
+ * Returns whether this thing is visible on the map or not. (Object)
*/
- void setPosition(const Point &p)
- { mPos = p; }
+ bool isVisible() const
+ { return mType != OBJECT_OTHER; }
/**
- * Gets the coordinates.
- *
- * @return the coordinates.
+ * Returns whether this thing can move on the map or not. (MovingObject)
*/
- Point const &getPosition() const
- { return mPos; }
+ bool canMove() const
+ { return mType == OBJECT_PLAYER || mType == OBJECT_MONSTER ||
+ mType == OBJECT_NPC; }
+
+ /**
+ * Returns whether this thing can fight or not. (Being)
+ */
+ bool canFight() const
+ { return mType == OBJECT_PLAYER || mType == OBJECT_MONSTER; }
/**
- * Update the internal status.
+ * Updates the internal status.
*/
virtual void
update() = 0;
/**
- * Gets the map the object is located on.
+ * Gets the map this thing is located on.
*
* @return ID of map.
*/
@@ -97,11 +107,46 @@ class Object
{ return mMapId; }
/**
- * Sets the map the object is located on.
+ * Sets the map this thing is located on.
*/
void setMapId(int mapId)
{ mMapId = mapId; }
+ private:
+ unsigned short mMapId; /**< id of the map being is on */
+ char mType; /**< Object type */
+};
+
+/**
+ * Generic client-visible object definition.
+ */
+class Object: public Thing
+{
+ public:
+ /**
+ * Constructor.
+ */
+ Object(int type)
+ : Thing(type),
+ mUpdateFlags(0)
+ {}
+
+ /**
+ * Sets the coordinates.
+ *
+ * @param p the coordinates.
+ */
+ void setPosition(const Point &p)
+ { mPos = p; }
+
+ /**
+ * Gets the coordinates.
+ *
+ * @return the coordinates.
+ */
+ Point const &getPosition() const
+ { return mPos; }
+
/**
* Gets what changed in the object.
*/
@@ -121,9 +166,7 @@ class Object
{ mUpdateFlags = 0; }
private:
- char mType; /**< Object type */
char mUpdateFlags; /**< changes in object status */
- unsigned short mMapId; /**< id of the map being is on */
Point mPos; /**< coordinates */
};
@@ -211,9 +254,4 @@ class MovingObject: public Object
unsigned short mActionTime; /**< delay until next action */
};
-/**
- * Type definition for a list of Objects.
- */
-typedef std::vector< Object * > Objects;
-
#endif // _TMWSERV_OBJECT_H_
diff --git a/src/point.h b/src/point.h
index 5ce87a53..74b8ab0e 100644
--- a/src/point.h
+++ b/src/point.h
@@ -23,10 +23,10 @@
#ifndef _TMWSERV_POINT_H_
#define _TMWSERV_POINT_H_
-#include "defines.h"
+#include <algorithm>
/**
- * A point in positive space. Usually representing pixel coordinates on a map.
+ * A point in positive space. Usually represents pixel coordinates on a map.
*/
class Point
{
@@ -35,13 +35,31 @@ class Point
unsigned short y; /**< y coordinate */
/**
- * Check whether the given point is within range of this point. This is
- * defined as lying within the distance of client awareness.
+ * Check whether the given point is within range of this point.
*/
- bool inRangeOf(const Point &p) const
+ bool inRangeOf(Point const &p, int radius) const
{
- return (abs(x - p.x) <= (int) AROUND_AREA &&
- abs(y - p.y) <= (int) AROUND_AREA);
+ return std::abs(x - p.x) <= radius &&
+ std::abs(y - p.y) <= radius;
+ }
+};
+
+/**
+ * A rectangle in positive space. Usually represents a pixel-based zone on a map.
+ */
+
+class Rectangle
+{
+ public:
+ unsigned short x; /**< x coordinate */
+ unsigned short y; /**< y coordinate */
+ unsigned short w; /**< width */
+ unsigned short h; /**< height */
+
+ bool contains(Point const &p) const
+ {
+ return (unsigned short)(p.x - x) < w &&
+ (unsigned short)(p.y - y) < h;
}
};
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
deleted file mode 100644
index aaf3af82..00000000
--- a/src/tests/Makefile.am
+++ /dev/null
@@ -1,47 +0,0 @@
-# $Id$
-
-
-if UNIT_TESTS_YES
-
-bin_PROGRAMS = tmwserv_test
-
-tmwserv_test_SOURCES = testsmain.cpp \
- testaccount.h \
- testaccount.cpp \
- testcipher.h \
- testcipher.cpp \
- testdataprovider.h \
- testdataprovider.cpp \
- testrecordset.h \
- testrecordset.cpp \
- teststorage.h \
- teststorage.cpp
-
-tmwserv_test_CXXFLAGS = -Wall $(CPPUNIT_CXXFLAGS)
-
-tmwserv_test_LDFLAGS = $(CPPUNIT_LIBS)
-
-tmwserv_test_LDADD = ../tmwserv-account.o \
- ../tmwserv-cipher.o \
- ../tmwserv-dalstorage.o \
- ../tmwserv-dataprovider.o \
- ../tmwserv-dataproviderfactory.o \
- ../tmwserv-logger.o \
- ../tmwserv-object.o \
- ../tmwserv-being.o \
- ../tmwserv-recordset.o \
- ../tmwserv-storage.o
-
-if BUILD_MYSQL
-tmwserv_test_LDADD += ../tmwserv-mysqldataprovider.o
-endif
-
-if BUILD_POSTGRESQL
-tmwserv_test_LDADD += ../tmwserv-pqdataprovider.o
-endif
-
-if BUILD_SQLITE
-tmwserv_test_LDADD += ../tmwserv-sqlitedataprovider.o
-endif
-
-endif
diff --git a/src/tests/testaccount.cpp b/src/tests/testaccount.cpp
deleted file mode 100644
index d30c8a78..00000000
--- a/src/tests/testaccount.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * The Mana World Server
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or any later version.
- *
- * The Mana World is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with The Mana World; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-
-#include "../utils/logger.h"
-#include "testaccount.h"
-
-
-// register the fixture into the 'registry'
-CPPUNIT_TEST_SUITE_REGISTRATION(AccountTest);
-
-
-using namespace tmwserv;
-
-
-/**
- * Set up fixtures.
- */
-void
-AccountTest::setUp(void)
-{
- const RawStatistics stats = {1, 1, 1, 1, 1, 1};
-
- BeingPtr sam(new Being("sam", GENDER_MALE, 0, 0, stats));
- BeingPtr merry(new Being("merry", GENDER_MALE, 0, 0, stats));
- BeingPtr pippin(new Being("pippin", GENDER_MALE, 0, 0, stats));
- mCharacters.push_back(sam);
- mCharacters.push_back(merry);
- mCharacters.push_back(pippin);
-
- mAccount = new Account("frodo",
- "baggins",
- "frodo@theshire.com",
- mCharacters);
-}
-
-
-/**
- * Tear down fixtures.
- */
-void
-AccountTest::tearDown(void)
-{
- delete mAccount;
- mAccount = 0;
-}
-
-
-/**
- * Test creating an Account passing the initial account info
- * to the constructor.
- */
-void
-AccountTest::testCreate1(void)
-{
- LOG("AccountTest::testCreate1()");
-
- const std::string name("frodo");
- const std::string password("baggins");
- const std::string email("frodo@theshire.com");
-
- Account account(name, password, email);
-
- CPPUNIT_ASSERT_EQUAL(name, account.getName());
- CPPUNIT_ASSERT_EQUAL(password, account.getPassword());
- CPPUNIT_ASSERT_EQUAL(email, account.getEmail());
- CPPUNIT_ASSERT_EQUAL((size_t) 0, account.getCharacters().size());
-}
-
-
-/**
- * Test creating an Account passing the initial account info
- * to the constructor.
- */
-void
-AccountTest::testCreate2(void)
-{
- LOG("AccountTest::testCreate2()");
-
- const std::string name("frodo");
- const std::string password("baggins");
- const std::string email("frodo@theshire.com");
-
- Account account(name, password, email, mCharacters);
-
- CPPUNIT_ASSERT_EQUAL(name, account.getName());
- CPPUNIT_ASSERT_EQUAL(password, account.getPassword());
- CPPUNIT_ASSERT_EQUAL(email, account.getEmail());
-
- CPPUNIT_ASSERT_EQUAL(mCharacters.size(),
- mAccount->getCharacters().size());
-
- const Beings& characters = account.getCharacters();
-
- for (size_t i = 0; i < mCharacters.size(); ++i) {
- CPPUNIT_ASSERT_EQUAL(characters[i]->getName(),
- mCharacters[i]->getName());
- }
-}
-
-
-/**
- * Test adding a new character.
- */
-void
-AccountTest::testAddCharacter1(void)
-{
- LOG("AccountTest::testAddCharacter1()");
-
- RawStatistics stats = {1, 1, 1, 1, 1, 1};
-
- BeingPtr bilbo(new Being("bilbo", GENDER_MALE, 0, 0, stats));
-
- mAccount->addCharacter(bilbo);
-
- CPPUNIT_ASSERT_EQUAL((size_t) 4, mAccount->getCharacters().size());
-
- std::vector<std::string> names;
- names.push_back("sam");
- names.push_back("merry");
- names.push_back("pippin");
- names.push_back("bilbo");
-
- for (size_t i = 0; i < mCharacters.size(); ++i) {
- CPPUNIT_ASSERT_EQUAL(names[i], mCharacters[i]->getName());
- }
-}
-
-
-/**
- * Test passing a NULL pointer to addCharacter().
- */
-void
-AccountTest::testAddCharacter2(void)
-{
- LOG("AccountTest::testAddCharacter2()");
-
- BeingPtr nullBeing(0);
-
- mAccount->addCharacter(nullBeing);
-
- CPPUNIT_ASSERT_EQUAL((size_t) 3, mAccount->getCharacters().size());
-
- std::vector<std::string> names;
- names.push_back("sam");
- names.push_back("merry");
- names.push_back("pippin");
-
- for (size_t i = 0; i < mCharacters.size(); ++i) {
- CPPUNIT_ASSERT_EQUAL(names[i], mCharacters[i]->getName());
- }
-}
-
-
-/**
- * Test the accessor getCharacter() with a valid name.
- */
-void
-AccountTest::testGetCharacter1(void)
-{
- LOG("AccountTest::testGetCharacter1()");
-
- const std::string name("merry");
-
- const Being* merry = mAccount->getCharacter(name);
-
- CPPUNIT_ASSERT(merry != 0);
- CPPUNIT_ASSERT_EQUAL(name, merry->getName());
-}
-
-
-/**
- * Test the accessor getCharacter() with an unexisting name.
- */
-void
-AccountTest::testGetCharacter2(void)
-{
- LOG("AccountTest::testGetCharacter2()");
-
- const Being* nobody = mAccount->getCharacter("johndoe");
-
- CPPUNIT_ASSERT(nobody == 0);
-}
diff --git a/src/tests/testaccount.h b/src/tests/testaccount.h
deleted file mode 100644
index 06a60bfc..00000000
--- a/src/tests/testaccount.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * The Mana World Server
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or any later version.
- *
- * The Mana World is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with The Mana World; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-
-#ifndef _TMWSERV_TEST_ACCOUNT_H_
-#define _TMWSERV_TEST_ACCOUNT_H_
-
-
-#include <cppunit/extensions/HelperMacros.h>
-
-#include "../account.h"
-
-
-/**
- * Unit test for the Account class.
- */
-class AccountTest: public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(AccountTest);
-
- // add tests to the test suite.
- CPPUNIT_TEST(testCreate1);
- CPPUNIT_TEST(testCreate2);
- CPPUNIT_TEST(testAddCharacter1);
- CPPUNIT_TEST(testAddCharacter2);
- CPPUNIT_TEST(testGetCharacter1);
- CPPUNIT_TEST(testGetCharacter2);
-
- CPPUNIT_TEST_SUITE_END();
-
-
- public:
- /**
- * Set up fixtures.
- */
- void
- setUp(void);
-
-
- /**
- * Tear down fixtures.
- */
- void
- tearDown(void);
-
-
- /**
- * Test creating an Account passing the initial account info
- * to the constructor.
- */
- void
- testCreate1(void);
-
-
- /**
- * Test creating an Account passing the initial account info
- * to the constructor.
- */
- void
- testCreate2(void);
-
-
- /**
- * Test adding a new character.
- */
- void
- testAddCharacter1(void);
-
-
- /**
- * Test passing a NULL pointer to addCharacter().
- */
- void
- testAddCharacter2(void);
-
-
- /**
- * Test the accessor getCharacter() with a valid name.
- */
- void
- testGetCharacter1(void);
-
-
- /**
- * Test the accessor getCharacter() with an unexisting name.
- */
- void
- testGetCharacter2(void);
-
-
- private:
- tmwserv::Account* mAccount; /**< the default account */
- tmwserv::Beings mCharacters; /**< a list of beings */
-};
-
-
-#endif // _TMWSERV_TEST_ACCOUNT_H_
diff --git a/src/tests/testcipher.cpp b/src/tests/testcipher.cpp
deleted file mode 100644
index 85e34099..00000000
--- a/src/tests/testcipher.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * The Mana World Server
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or any later version.
- *
- * The Mana World is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with The Mana World; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-
-#include <string>
-
-#include "../utils/cipher.h"
-#include "../utils/logger.h"
-#include "testcipher.h"
-
-
-// register the fixture into the 'registry'
-CPPUNIT_TEST_SUITE_REGISTRATION(CipherTest);
-
-
-using namespace tmwserv::utils;
-
-
-/**
- * Set up fixtures.
- */
-void
-CipherTest::setUp(void)
-{
- // NOOP
-}
-
-
-/**
- * Tear down fixtures.
- */
-void
-CipherTest::tearDown(void)
-{
- // NOOP
-}
-
-
-/**
- * Test encoding a string with the MD5 digest algorithm.
- */
-void
-CipherTest::testMd5_1(void)
-{
- LOG("CipherTest::testMd5_1()");
-
- const std::string expected("d41d8cd98f00b204e9800998ecf8427e");
- const std::string actual(Cipher::instance().md5(""));
-
- CPPUNIT_ASSERT_EQUAL(expected, actual);
-}
-
-
-/**
- * Test encoding a string with the MD5 digest algorithm.
- */
-void
-CipherTest::testMd5_2(void)
-{
- LOG("CipherTest::testMd5_2()");
-
- const std::string expected("0cc175b9c0f1b6a831c399e269772661");
- const std::string actual(Cipher::instance().md5("a"));
-
- CPPUNIT_ASSERT_EQUAL(expected, actual);
-}
-
-
-/**
- * Test encoding a string with the MD5 digest algorithm.
- */
-void
-CipherTest::testMd5_3(void)
-{
- LOG("CipherTest::testMd5_3()");
-
- const std::string expected("900150983cd24fb0d6963f7d28e17f72");
- const std::string actual(Cipher::instance().md5("abc"));
-
- CPPUNIT_ASSERT_EQUAL(expected, actual);
-}
-
-
-/**
- * Test encoding a string with the MD5 digest algorithm.
- */
-void
-CipherTest::testMd5_4(void)
-{
- LOG("CipherTest::testMd5_4()");
-
- const std::string expected("f96b697d7cb7938d525a2f31aaf161d0");
- const std::string actual(Cipher::instance().md5("message digest"));
-
- CPPUNIT_ASSERT_EQUAL(expected, actual);
-}
-
-
-/**
- * Test encoding a string with the MD5 digest algorithm.
- */
-void
-CipherTest::testMd5_5(void)
-{
- LOG("CipherTest::testMd5_6()");
-
- const std::string expected("c3fcd3d76192e4007dfb496cca67e13b");
- const std::string actual(
- Cipher::instance().md5("abcdefghijklmnopqrstuvwxyz"));
-
- CPPUNIT_ASSERT_EQUAL(expected, actual);
-}
-
-
-/**
- * Test encoding a string with the MD5 digest algorithm.
- */
-void
-CipherTest::testMd5_6(void)
-{
- LOG("CipherTest::testMd5_6()");
-
- const std::string expected("d174ab98d277d9f5a5611c2c9f419d9f");
-
- std::string s("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
- s += "abcdefghijklmnopqrstuvwxyz";
- s += "0123456789";
- const std::string actual(Cipher::instance().md5(s));
-
- CPPUNIT_ASSERT_EQUAL(expected, actual);
-}
-
-
-/**
- * Test encoding a string with the MD5 digest algorithm.
- */
-void
-CipherTest::testMd5_7(void)
-{
- LOG("CipherTest::testMd5_7()");
-
- const std::string expected("57edf4a22be3c955ac49da2e2107b67a");
-
- std::string s;
- for (int i = 0; i < 8; ++i) {
- s += "1234567890";
- }
- const std::string actual(Cipher::instance().md5(s));
-
- CPPUNIT_ASSERT_EQUAL(expected, actual);
-}
diff --git a/src/tests/testcipher.h b/src/tests/testcipher.h
deleted file mode 100644
index 7db81803..00000000
--- a/src/tests/testcipher.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * The Mana World Server
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or any later version.
- *
- * The Mana World is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with The Mana World; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-
-#ifndef _TMWSERV_TEST_CIPHER_H_
-#define _TMWSERV_TEST_CIPHER_H_
-
-
-#include <cppunit/extensions/HelperMacros.h>
-
-
-/**
- * Unit test for the Cipher class.
- */
-class CipherTest: public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(CipherTest);
-
- // add tests to the test suite.
- CPPUNIT_TEST(testMd5_1);
- CPPUNIT_TEST(testMd5_2);
- CPPUNIT_TEST(testMd5_3);
- CPPUNIT_TEST(testMd5_4);
- CPPUNIT_TEST(testMd5_5);
- CPPUNIT_TEST(testMd5_6);
- CPPUNIT_TEST(testMd5_7);
-
- CPPUNIT_TEST_SUITE_END();
-
-
- public:
- /**
- * Set up fixtures.
- */
- void
- setUp(void);
-
-
- /**
- * Tear down fixtures.
- */
- void
- tearDown(void);
-
-
- /**
- * Test encoding a string with the MD5 digest algorithm.
- */
- void
- testMd5_1(void);
-
-
- /**
- * Test encoding a string with the MD5 digest algorithm.
- */
- void
- testMd5_2(void);
-
-
- /**
- * Test encoding a string with the MD5 digest algorithm.
- */
- void
- testMd5_3(void);
-
-
- /**
- * Test encoding a string with the MD5 digest algorithm.
- */
- void
- testMd5_4(void);
-
-
- /**
- * Test encoding a string with the MD5 digest algorithm.
- */
- void
- testMd5_5(void);
-
-
- /**
- * Test encoding a string with the MD5 digest algorithm.
- */
- void
- testMd5_6(void);
-
-
- /**
- * Test encoding a string with the MD5 digest algorithm.
- */
- void
- testMd5_7(void);
-};
-
-
-#endif // _TMWSERV_TEST_CIPHER_H_
diff --git a/src/tests/testdataprovider.cpp b/src/tests/testdataprovider.cpp
deleted file mode 100644
index dd5aff4f..00000000
--- a/src/tests/testdataprovider.cpp
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * The Mana World Server
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or any later version.
- *
- * The Mana World is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with The Mana World; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-
-#include <physfs.h>
-
-#if defined (MYSQL_SUPPORT)
-#include <mysql/mysql.h>
-#elif defined (POSTGRE_SUPPORT)
-#include <libpq-fe.h>
-#endif
-
-#include "../dal/dataproviderfactory.h"
-#include "../utils/logger.h"
-
-#include "testdataprovider.h"
-
-
-// register the fixture into the 'registry'
-CPPUNIT_TEST_SUITE_REGISTRATION(DataProviderTest);
-
-
-// initialize the static variables.
-std::string DataProviderTest::mDbName("tmwteststorage");
-std::string DataProviderTest::mDbUser("guest");
-std::string DataProviderTest::mDbPassword("guest");
-std::string DataProviderTest::mSqlCreateTable(
- "create table employees ("
- " id integer primary key, "
- " name varchar(32) not null);"
-);
-std::string DataProviderTest::mSqlInsertRow(
- "insert into employees values (1, 'john');"
-);
-std::string DataProviderTest::mSqlFetchRow("select * from employees;");
-
-
-using namespace tmwserv::dal;
-
-
-/**
- * Set up fixtures.
- */
-void
-DataProviderTest::setUp(void)
-{
- // reinitialize the database before each test.
- reinitDb();
-
- // obtain a data provider.
- try {
- mDb = DataProviderFactory::createDataProvider();
- }
- catch (const std::runtime_error& e) {
- CPPUNIT_FAIL(e.what());
- }
-}
-
-
-/**
- * Tear down fixtures.
- */
-void
-DataProviderTest::tearDown(void)
-{
- mDb->disconnect();
-
- delete mDb;
- mDb = 0;
-
- // clean the database after each test.
- reinitDb();
-}
-
-
-/**
- * Connection to an existing database.
- */
-void
-DataProviderTest::testConnection1(void)
-{
- LOG("DataProviderTest::testConnection1()");
-
-#ifdef SQLITE_SUPPORT
- std::string dbFile(mDbName);
- dbFile += ".db";
-
- mDb->connect(dbFile, mDbUser, mDbPassword);
-#else
- mDb->connect(mDbName, mDbUser, mDbPassword);
-#endif
-
- CPPUNIT_ASSERT(mDb->isConnected());
-}
-
-
-/**
- * Create a new table in the database.
- */
-void
-DataProviderTest::testCreateTable1(void)
-{
- LOG("DataProviderTest::testCreateTable1()");
-
-#ifdef SQLITE_SUPPORT
- std::string dbFile(mDbName);
- dbFile += ".db";
-
- mDb->connect(dbFile, mDbUser, mDbPassword);
-#else
- mDb->connect(mDbName, mDbUser, mDbPassword);
-#endif
-
- CPPUNIT_ASSERT(mDb->isConnected());
-
- const RecordSet& rs = mDb->execSql(mSqlCreateTable);
- CPPUNIT_ASSERT(rs.isEmpty());
-
- mDb->disconnect();
- CPPUNIT_ASSERT(!mDb->isConnected());
-}
-
-
-/**
- * Create the same table one more time in the database.
- */
-void
-DataProviderTest::testCreateTable2(void)
-{
- LOG("DataProviderTest::testCreateTable2()");
-
-#ifdef SQLITE_SUPPORT
- std::string dbFile(mDbName);
- dbFile += ".db";
-
- mDb->connect(dbFile, mDbUser, mDbPassword);
-#else
- mDb->connect(mDbName, mDbUser, mDbPassword);
-#endif
-
- CPPUNIT_ASSERT(mDb->isConnected());
-
- mDb->execSql(mSqlCreateTable);
- // this should throw tmwserv::dal::DbSqlQueryExecFailure.
- mDb->execSql(mSqlCreateTable);
-}
-
-
-/**
- * Insert a new row to the table.
- */
-void
-DataProviderTest::testInsert1(void)
-{
- LOG("DataProviderTest::testInsert1()");
-
-#ifdef SQLITE_SUPPORT
- std::string dbFile(mDbName);
- dbFile += ".db";
-
- mDb->connect(dbFile, mDbUser, mDbPassword);
-#else
- mDb->connect(mDbName, mDbUser, mDbPassword);
-#endif
-
- CPPUNIT_ASSERT(mDb->isConnected());
-
- mDb->execSql(mSqlCreateTable);
-
- const RecordSet& rs = mDb->execSql(mSqlInsertRow);
- // an insert query does not return any records
- // so the recordset remains empty.
- CPPUNIT_ASSERT(rs.isEmpty());
-
- mDb->disconnect();
- CPPUNIT_ASSERT(!mDb->isConnected());
-}
-
-
-/**
- * Insert the same record again.
- */
-void
-DataProviderTest::testInsert2(void)
-{
- LOG("DataProviderTest::testInsert2()");
-
-#ifdef SQLITE_SUPPORT
- std::string dbFile(mDbName);
- dbFile += ".db";
-
- mDb->connect(dbFile, mDbUser, mDbPassword);
-#else
- mDb->connect(mDbName, mDbUser, mDbPassword);
-#endif
-
- CPPUNIT_ASSERT(mDb->isConnected());
-
- // this should throw tmwserv::dal::DbSqlQueryExecFailure
- // as we are violating the primary key uniqueness.
- mDb->execSql(mSqlInsertRow);
-}
-
-
-/**
- * Fetch data from the table.
- */
-void
-DataProviderTest::testFetch1(void)
-{
- LOG("DataProviderTest::testFetch1()");
-
-#ifdef SQLITE_SUPPORT
- std::string dbFile(mDbName);
- dbFile += ".db";
-
- mDb->connect(dbFile, mDbUser, mDbPassword);
-#else
- mDb->connect(mDbName, mDbUser, mDbPassword);
-#endif
-
- CPPUNIT_ASSERT(mDb->isConnected());
-
- mDb->execSql(mSqlCreateTable);
- mDb->execSql(mSqlInsertRow);
-
- const RecordSet& rs = mDb->execSql(mSqlFetchRow);
- CPPUNIT_ASSERT(!rs.isEmpty());
-
- std::string id("1");
- std::string name("john");
- CPPUNIT_ASSERT_EQUAL(id, rs(0, "id"));
- CPPUNIT_ASSERT_EQUAL(name, rs(0, "name"));
-
- mDb->disconnect();
- CPPUNIT_ASSERT(!mDb->isConnected());
-}
-
-
-/**
- * Disconnection from an open database.
- */
-void
-DataProviderTest::testDisconnection1(void)
-{
- LOG("DataProviderTest::testDisconnection1()");
-
-#ifdef SQLITE_SUPPORT
- std::string dbFile(mDbName);
- dbFile += ".db";
-
- mDb->connect(dbFile, mDbUser, mDbPassword);
-#else
- mDb->connect(mDbName, mDbUser, mDbPassword);
-#endif
-
- CPPUNIT_ASSERT(mDb->isConnected());
-
- mDb->disconnect();
- CPPUNIT_ASSERT(!mDb->isConnected());
-}
-
-
-/**
- * Disconnection from a closed database.
- */
-void
-DataProviderTest::testDisconnection2(void)
-{
- LOG("DataProviderTest::testDisconnection2()");
-
- mDb->disconnect();
- CPPUNIT_ASSERT(!mDb->isConnected());
-}
-
-
-/**
- * Reinitialize the database.
- */
-void
-DataProviderTest::reinitDb(void)
-{
- // we are not using DataProvider::execSql() to execute the SQL queries
- // here as the class is the purpose of these tests.
-
-#if defined (MYSQL_SUPPORT)
- {
- // initialize the MySQL library.
- MYSQL* db = mysql_init(NULL);
-
- if (!db) {
- CPPUNIT_FAIL("unable to initialize the MySQL library: no memory");
- }
-
- // connect to the database.
- if (!mysql_real_connect(db,
- NULL,
- mDbUser.c_str(),
- mDbPassword.c_str(),
- mDbName.c_str(),
- 0,
- NULL,
- 0))
- {
- CPPUNIT_FAIL(mysql_error(db));
- }
-
- // drop the table.
- std::string sql("drop table employees;");
- if (mysql_query(db, sql.c_str()) != 0) {
- // ignore, the table may not exist.
- }
-
- // close the connection and free memory.
- mysql_close(db);
- mysql_library_end();
- db = 0;
- }
-#elif defined (POSTGRE_SUPPORT)
- // TODO: drop tables.
-#else // SQLITE_SUPPORT
- std::string dbFile(mDbName);
- dbFile += ".db";
-
- // ensure that the database file does not exist.
- if (PHYSFS_exists(dbFile.c_str())) {
- if (PHYSFS_delete(dbFile.c_str()) == 0) {
- CPPUNIT_FAIL(PHYSFS_getLastError());
- }
- }
-#endif
-}
diff --git a/src/tests/testdataprovider.h b/src/tests/testdataprovider.h
deleted file mode 100644
index 1f0a082c..00000000
--- a/src/tests/testdataprovider.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * The Mana World Server
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or any later version.
- *
- * The Mana World is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with The Mana World; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-
-#ifndef _TMWSERV_TEST_DATA_PROVIDER_H_
-#define _TMWSERV_TEST_DATA_PROVIDER_H_
-
-
-#include <cppunit/extensions/HelperMacros.h>
-
-#include "../dal/dalexcept.h"
-#include "../dal/dataprovider.h"
-
-
-/**
- * Requirements:
- * - if using MySQL or PostgreSQL as backends, then make sure that a user
- * named 'guest' with the password 'guest' has enough privileges to
- * create tables and populate them in a database named 'tmwteststorage'
- * prior to running the teststorage unit tests.
- */
-
-
-using namespace tmwserv::dal;
-
-
-/**
- * Unit test for the DataProvider class.
- */
-class DataProviderTest: public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(DataProviderTest);
-
- // add tests to the test suite.
- CPPUNIT_TEST(testConnection1);
- CPPUNIT_TEST(testCreateTable1);
- CPPUNIT_TEST_EXCEPTION(testCreateTable2, DbSqlQueryExecFailure);
- CPPUNIT_TEST(testInsert1);
- CPPUNIT_TEST_EXCEPTION(testInsert2, DbSqlQueryExecFailure);
- CPPUNIT_TEST(testFetch1);
- CPPUNIT_TEST(testDisconnection1);
- CPPUNIT_TEST(testDisconnection2);
-
- CPPUNIT_TEST_SUITE_END();
-
-
- public:
- /**
- * Set up fixtures.
- */
- void
- setUp(void);
-
-
- /**
- * Tear down fixtures.
- */
- void
- tearDown(void);
-
-
- /**
- * Connection to an existing database.
- */
- void
- testConnection1(void);
-
-
- /**
- * Create a new table in the database.
- */
- void
- testCreateTable1(void);
-
-
- /**
- * Create the same table one more time in the database.
- */
- void
- testCreateTable2(void);
-
-
- /**
- * Insert a new record into the table.
- */
- void
- testInsert1(void);
-
-
- /**
- * Insert the same record again.
- */
- void
- testInsert2(void);
-
-
- /**
- * Fetch data from the table.
- */
- void
- testFetch1(void);
-
-
- /**
- * Disconnection from an open database.
- */
- void
- testDisconnection1(void);
-
-
- /**
- * Disconnection from a closed database.
- */
- void
- testDisconnection2(void);
-
-
- private:
- /**
- * Reinitialize the database.
- */
- void
- reinitDb(void);
-
-
- private:
- DataProvider* mDb; /**< the data provider */
- static std::string mDbName; /**< the database name */
- static std::string mDbUser; /**< the database user */
- static std::string mDbPassword; /**< the database password */
- static std::string mSqlCreateTable; /**< SQL query to create table */
- static std::string mSqlInsertRow; /**< SQL query to delete table */
- static std::string mSqlFetchRow; /**< SQL query to fetch data */
-};
-
-
-#endif // _TMWSERV_TEST_DATA_PROVIDER_H_
diff --git a/src/tests/testrecordset.cpp b/src/tests/testrecordset.cpp
deleted file mode 100644
index df9a7100..00000000
--- a/src/tests/testrecordset.cpp
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * The Mana World Server
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or any later version.
- *
- * The Mana World is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with The Mana World; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-
-#include <sstream>
-
-#include "../utils/logger.h"
-#include "testrecordset.h"
-
-
-// register the fixture into the 'registry'
-CPPUNIT_TEST_SUITE_REGISTRATION(RecordSetTest);
-
-
-using namespace tmwserv::dal;
-
-
-/**
- * Set up fixtures.
- */
-void
-RecordSetTest::setUp(void)
-{
- // populate mNonEmptyRs.
- Row headers;
- headers.push_back("id");
- headers.push_back("name");
- mNonEmptyRs.setColumnHeaders(headers);
-
- Row r1;
- r1.push_back("1");
- r1.push_back("john");
- mNonEmptyRs.add(r1);
-
- Row r2;
- r2.push_back("2");
- r2.push_back("mike");
- mNonEmptyRs.add(r2);
-}
-
-
-/**
- * Tear down fixtures.
- */
-void
-RecordSetTest::tearDown(void)
-{
- // NOOP
-}
-
-
-/**
- * Test RecordSet::rows() on an empty RecordSet.
- */
-void
-RecordSetTest::testRows1(void)
-{
- LOG("RecordSetTest::testRows1()");
-
- CPPUNIT_ASSERT_EQUAL((unsigned int) 0, mEmptyRs.rows());
-}
-
-
-/**
- * Test RecordSet::rows() on a non-empty RecordSet.
- */
-void
-RecordSetTest::testRows2(void)
-{
- LOG("RecordSetTest::testRows2()");
-
- CPPUNIT_ASSERT_EQUAL((unsigned int) 2, mNonEmptyRs.rows());
-}
-
-
-/**
- * Test RecordSet::cols() on an empty RecordSet.
- */
-void
-RecordSetTest::testCols1(void)
-{
- LOG("RecordSetTest::testCols1()");
-
- CPPUNIT_ASSERT_EQUAL((unsigned int) 0, mEmptyRs.cols());
-}
-
-
-/**
- * Test RecordSet::cols() on a non-empty RecordSet.
- */
-void
-RecordSetTest::testCols2(void)
-{
- LOG("RecordSetTest::testCols2()");
-
- CPPUNIT_ASSERT_EQUAL((unsigned int) 2, mNonEmptyRs.cols());
-}
-
-
-/**
- * Call RecordSet::isEmpty() from an empty RecordSet.
- */
-void
-RecordSetTest::testIsEmpty1(void)
-{
- LOG("RecordSetTest::testIsEmpty1()");
-
- CPPUNIT_ASSERT(mEmptyRs.isEmpty());
-}
-
-
-/**
- * Call RecordSet::isEmpty() from a non-empty RecordSet.
- */
-void
-RecordSetTest::testIsEmpty2(void)
-{
- LOG("RecordSetTest::testIsEmpty2()");
-
- CPPUNIT_ASSERT(!mNonEmptyRs.isEmpty());
-}
-
-
-/**
- * Call RecordSet::operator() from an empty RecordSet.
- */
-void
-RecordSetTest::testOperator1(void)
-{
- LOG("RecordSetTest::testOperator1()");
-
- // this should throw std::invalid_argument.
- mEmptyRs(0, 0);
-}
-
-
-/**
- * Call RecordSet::operator() from a non-empty RecordSet with
- * a row index and a column index as parameters.
- */
-void
-RecordSetTest::testOperator2(void)
-{
- LOG("RecordSetTest::testRows1()");
-
- const std::string value("mike");
-
- CPPUNIT_ASSERT_EQUAL(value, mNonEmptyRs(1, 1));
-}
-
-
-/**
- * Call RecordSet::operator() from a non-empty RecordSet with
- * a row index and a column index that are out of range as
- * parameters.
- */
-void
-RecordSetTest::testOperator3(void)
-{
- LOG("RecordSetTest::testOperator3()");
-
- // this should throw std::out_of_range.
- mNonEmptyRs(2, 2);
-}
-
-
-/**
- * Call RecordSet::operator() from a non-empty RecordSet with
- * a row index and a field name as parameters.
- */
-void
-RecordSetTest::testOperator4(void)
-{
- LOG("RecordSetTest::testOperator4()");
-
- const std::string value("1");
-
- CPPUNIT_ASSERT_EQUAL(value, mNonEmptyRs(0, "id"));
-}
-
-
-/**
- * Call RecordSet::operator() from a non-empty RecordSet with
- * a row index that is out of range and a field name as parameters.
- */
-void
-RecordSetTest::testOperator5(void)
-{
- LOG("RecordSetTest::testOperator5()");
-
- // this should throw std::out_of_range.
- mNonEmptyRs(3, "id");
-}
-
-
-/**
- * Call RecordSet::operator() from a non-empty RecordSet with
- * a row index and a field name that does not exist as parameters.
- */
-void
-RecordSetTest::testOperator6(void)
-{
- LOG("RecordSetTest::testOperator6()");
-
- // this should throw std::invalid_argument.
- mNonEmptyRs(1, "noname");
-}
-
-
-/**
- * Test writing an empty RecordSet to an output stream.
- */
-void
-RecordSetTest::testOutputStream1(void)
-{
- LOG("RecordSetTest::testOutputStream1()");
-
- const std::string emptyStr;
-
- std::ostringstream os;
- os << mEmptyRs;
-
- CPPUNIT_ASSERT_EQUAL(emptyStr, os.str());
-}
-
-
-/**
- * Test writing a non-empty RecordSet to an output stream.
- */
-void
-RecordSetTest::testOutputStream2(void)
-{
- LOG("RecordSetTest::testOutputStream2()");
-
- std::ostringstream os1;
- os1 << "|id|name|" << std::endl << std::endl
- << "|1|john|" << std::endl
- << "|2|mike|" << std::endl;
-
- std::ostringstream os2;
- os2 << mNonEmptyRs;
-
- CPPUNIT_ASSERT_EQUAL(os1.str(), os2.str());
-}
-
-
-/**
- * Test RecordSet::add() to add a new now.
- */
-void
-RecordSetTest::testAdd1(void)
-{
- LOG("RecordSetTest::testAdd1()");
-
- const std::string id("3");
- const std::string name("elena");
-
- Row r;
- r.push_back(id);
- r.push_back(name);
- mNonEmptyRs.add(r);
-
- CPPUNIT_ASSERT_EQUAL((unsigned int) 3, mNonEmptyRs.rows());
- CPPUNIT_ASSERT_EQUAL((unsigned int) 2, mNonEmptyRs.cols());
- CPPUNIT_ASSERT_EQUAL(id, mNonEmptyRs(2, 0));
- CPPUNIT_ASSERT_EQUAL(name, mNonEmptyRs(2, 1));
-}
-
-
-/**
- * Test RecordSet::add() to add a new now with a different number
- * of fields.
- */
-void
-RecordSetTest::testAdd2(void)
-{
- LOG("RecordSetTest::testAdd2()");
-
- Row r;
- r.push_back("4");
-
- // this should throw std::invalid_argument.
- mNonEmptyRs.add(r);
-}
-
-
-/**
- * Test RecordSet::add() to add a new now to a RecordSet that does
- * not have column headers.
- */
-void
-RecordSetTest::testAdd3(void)
-{
- LOG("RecordSetTest::testAdd3()");
-
- Row r;
- r.push_back("5");
-
- // this should throw tmw::dal::RsColumnHeadersNotSet.
- mEmptyRs.add(r);
-}
diff --git a/src/tests/testrecordset.h b/src/tests/testrecordset.h
deleted file mode 100644
index 66dc7117..00000000
--- a/src/tests/testrecordset.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * The Mana World Server
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or any later version.
- *
- * The Mana World is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with The Mana World; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-
-#ifndef _TMWSERV_TEST_RECORDSET_H_
-#define _TMWSERV_TEST_RECORDSET_H_
-
-
-#include <cppunit/extensions/HelperMacros.h>
-
-#include <stdexcept>
-
-#include "../dal/dalexcept.h"
-#include "../dal/recordset.h"
-
-
-using namespace tmwserv::dal;
-
-
-/**
- * Unit test for the RecordSet class.
- */
-class RecordSetTest: public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(RecordSetTest);
-
- // add tests to the test suite.
- CPPUNIT_TEST(testRows1);
- CPPUNIT_TEST(testRows2);
- CPPUNIT_TEST(testCols1);
- CPPUNIT_TEST(testCols2);
- CPPUNIT_TEST(testIsEmpty1);
- CPPUNIT_TEST(testIsEmpty2);
- CPPUNIT_TEST_EXCEPTION(testOperator1, std::invalid_argument);
- CPPUNIT_TEST(testOperator2);
- CPPUNIT_TEST_EXCEPTION(testOperator3, std::out_of_range);
- CPPUNIT_TEST(testOperator4);
- CPPUNIT_TEST_EXCEPTION(testOperator5, std::out_of_range);
- CPPUNIT_TEST_EXCEPTION(testOperator6, std::invalid_argument);
- CPPUNIT_TEST(testOutputStream1);
- CPPUNIT_TEST(testOutputStream2);
- CPPUNIT_TEST(testAdd1);
- CPPUNIT_TEST_EXCEPTION(testAdd2, std::invalid_argument);
- CPPUNIT_TEST_EXCEPTION(testAdd3, RsColumnHeadersNotSet);
-
- CPPUNIT_TEST_SUITE_END();
-
-
- public:
- /**
- * Set up fixtures.
- */
- void
- setUp(void);
-
-
- /**
- * Tear down fixtures.
- */
- void
- tearDown(void);
-
-
- /**
- * Call RecordSet::rows() from an empty RecordSet.
- */
- void
- testRows1(void);
-
-
- /**
- * Call RecordSet::rows() from a non-empty RecordSet.
- */
- void
- testRows2(void);
-
-
- /**
- * Call RecordSet::cols() from an empty RecordSet.
- */
- void
- testCols1(void);
-
-
- /**
- * Call RecordSet::cols() from a non-empty RecordSet.
- */
- void
- testCols2(void);
-
-
- /**
- * Call RecordSet::isEmpty() from an empty RecordSet.
- */
- void
- testIsEmpty1(void);
-
-
- /**
- * Call RecordSet::isEmpty() from a non-empty RecordSet.
- */
- void
- testIsEmpty2(void);
-
-
- /**
- * Call RecordSet::operator() from an empty RecordSet.
- */
- void
- testOperator1(void);
-
-
- /**
- * Call RecordSet::operator() from a non-empty RecordSet with
- * a row index and a column index as parameters.
- */
- void
- testOperator2(void);
-
- /**
- * Call RecordSet::operator() from a non-empty RecordSet with
- * a row index and a column index that are out of range as
- * parameters.
- */
- void
- testOperator3(void);
-
-
- /**
- * Call RecordSet::operator() from a non-empty RecordSet with
- * a row index and a field name as parameters.
- */
- void
- testOperator4(void);
-
-
- /**
- * Call RecordSet::operator() from a non-empty RecordSet with
- * a row index that is out of range and a field name as parameters.
- */
- void
- testOperator5(void);
-
-
- /**
- * Call RecordSet::operator() from a non-empty RecordSet with
- * a row index and a field name that does not exist as parameters.
- */
- void
- testOperator6(void);
-
-
- /**
- * Test writing an empty RecordSet to an output stream.
- */
- void
- testOutputStream1(void);
-
-
- /**
- * Test writing a non-empty RecordSet to an output stream.
- */
- void
- testOutputStream2(void);
-
-
- /**
- * Call RecordSet::add() to add a new now.
- */
- void
- testAdd1(void);
-
-
- /**
- * Call RecordSet::add() to add a new now with a different number
- * of fields.
- */
- void
- testAdd2(void);
-
-
- /**
- * Call RecordSet::add() to add a new now to a RecordSet that does
- * not have column headers.
- */
- void
- testAdd3(void);
-
-
- private:
- RecordSet mEmptyRs; /**< empty recordset */
- RecordSet mNonEmptyRs; /**< recordset with some data */
-};
-
-
-#endif // _TMWSERV_TEST_RECORDSET_H_
diff --git a/src/tests/testsmain.cpp b/src/tests/testsmain.cpp
deleted file mode 100644
index 21237601..00000000
--- a/src/tests/testsmain.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * The Mana World Server
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or any later version.
- *
- * The Mana World is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with The Mana World; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-
-#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <cppunit/ui/text/TextTestRunner.h>
-
-#include <physfs.h>
-
-#include "../utils/logger.h"
-
-
-/**
- * Notes:
- * - if the unit test application is linked to libsqlite3, there will
- * be a memory leak (8 bytes) while no leaks are detected when linked
- * to libmysqlclient. the leak was detected using Valgrind, an
- * excellent memory debugger.
- *
- * TODO: check memory leak when linked to libpq (PostgreSQL).
- */
-
-
-int main(int argc, char* argv[])
-{
- // initialize the PhysicsFS library.
- PHYSFS_init(argv[0]);
- PHYSFS_addToSearchPath(".", 1);
- PHYSFS_setWriteDir(".");
-
- // initialize the logger.
- tmwserv::utils::Logger::instance().setTimestamp(false);
-
- using namespace CppUnit;
-
- // get the top level suite from the registry.
- Test* suite = TestFactoryRegistry::getRegistry().makeTest();
-
- // add the test to the list of test to run.
- TextTestRunner runner;
- runner.addTest(suite);
-
- // run the tests.
- bool wasSuccessful = runner.run();
-
- // denitialize the PhysicsFS library.
- PHYSFS_deinit();
-
- // return error code 1 if the one of test failed.
- return wasSuccessful ? 0 : 1;
-}
diff --git a/src/tests/teststorage.cpp b/src/tests/teststorage.cpp
deleted file mode 100644
index c8436289..00000000
--- a/src/tests/teststorage.cpp
+++ /dev/null
@@ -1,746 +0,0 @@
-/*
- * The Mana World Server
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or any later version.
- *
- * The Mana World is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with The Mana World; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-
-#if !defined (MYSQL_SUPPORT) && !defined (SQLITE_SUPPORT) && \
- !defined (POSTGRESQL_SUPPORT)
-
- // if we are in this block it means that we are not using a database
- // to persist the data from the storage.
- // at the moment, Storage assume that the data are persisted in a database
- // so let's raise a preprocessing error.
-#error "no database backend defined"
-#endif
-
-
-#include <sstream>
-
-#include <physfs.h>
-
-#include "../utils/cipher.h"
-#include "../utils/functors.h"
-#include "../utils/logger.h"
-#include "../dalstoragesql.h"
-#include "../storage.h"
-#include "teststorage.h"
-
-
-// register the fixture into the 'registry'
-CPPUNIT_TEST_SUITE_REGISTRATION(StorageTest);
-
-
-// initialization of static attributes.
-std::string StorageTest::mStorageName("tmwteststorage");
-std::string StorageTest::mStorageUser("guest");
-std::string StorageTest::mStorageUserPassword("guest");
-
-
-using namespace tmwserv;
-
-
-/**
- * Set up fixtures.
- */
-void
-StorageTest::setUp(void)
-{
- // reinitialize the storage before each test.
- initStorage();
-
- // create a storage.
- Storage& myStorage = Storage::instance(mStorageName);
- myStorage.setUser(mStorageUser);
- myStorage.setPassword(mStorageUserPassword);
-
- // open the storage.
- myStorage.open();
-}
-
-
-/**
- * Tear down fixtures.
- */
-void
-StorageTest::tearDown(void)
-{
- // close the storage.
- Storage& myStorage = Storage::instance(mStorageName);
- myStorage.close();
-
- // delete the storage.
- Storage::destroy();
-
- // clean the storage after each test.
- cleanStorage();
-}
-
-
-/**
- * Fetch an existing account from the database.
- */
-void
-StorageTest::testGetAccount1(void)
-{
- LOG("StorageTest::testGetAccount1()");
-
- Storage& myStorage = Storage::instance(mStorageName);
-
- CPPUNIT_ASSERT(myStorage.isOpen());
-
- const std::string name("frodo");
- Account* account = myStorage.getAccount(name);
-
- using namespace tmwserv::utils;
-
- const std::string password(Cipher::instance().md5(name));
- const std::string email("frodo@domain");
-
- CPPUNIT_ASSERT(account != 0);
- CPPUNIT_ASSERT_EQUAL(name, account->getName());
- CPPUNIT_ASSERT_EQUAL(password, account->getPassword());
- CPPUNIT_ASSERT_EQUAL(email, account->getEmail());
-}
-
-
-/**
- * Fetch an unexisting account from the database.
- */
-void
-StorageTest::testGetAccount2(void)
-{
- LOG("StorageTest::testGetAccount2()");
-
- Storage& myStorage = Storage::instance(mStorageName);
-
- CPPUNIT_ASSERT(myStorage.isOpen());
-
- Account* account = myStorage.getAccount("xxx");
-
- CPPUNIT_ASSERT(account == 0);
-}
-
-
-/**
- * Test passing a null pointer to addAcccount().
- */
-void
-StorageTest::testAddAccount1(void)
-{
- LOG("StorageTest::testAddAccount1()");
-
- Storage& myStorage = Storage::instance(mStorageName);
-
- CPPUNIT_ASSERT(myStorage.isOpen());
-
- // TODO: when addAccount will throw exceptions, test the exceptions
- // thrown.
- // nothing should happen at the moment.
- AccountPtr nullAccount(0);
- myStorage.addAccount(nullAccount);
- myStorage.flush();
-
- // check the database.
- Checks checks;
- checks.set(CHK_DEFAULT_ACCOUNTS);
- checkDb(checks);
-}
-
-
-/**
- * Test adding a new account.
- */
-void
-StorageTest::testAddAccount2(void)
-{
- LOG("StorageTest::testAddAccount2()");
-
- Storage& myStorage = Storage::instance(mStorageName);
-
- CPPUNIT_ASSERT(myStorage.isOpen());
-
- // prepare new account.
- RawStatistics stats = {1, 1, 1, 1, 1, 1};
-
- BeingPtr b1(new Being("sam1", GENDER_MALE, 0, 0, stats));
- BeingPtr b2(new Being("sam2", GENDER_MALE, 0, 0, stats));
- Beings characters;
- characters.push_back(b1);
- characters.push_back(b2);
-
- const std::string sam("sam");
- AccountPtr acc(new Account(sam, sam, "sam@domain", characters));
-
- // TODO: when addAccount will throw exceptions, test the exceptions
- // thrown.
- myStorage.addAccount(acc);
- myStorage.flush();
-
- // check the database.
- Checks checks;
- checks.set(CHK_NEW_ADDED_ACCOUNT);
- checks.set(CHK_CHARACTERS_4);
- checkDb(checks);
-}
-
-
-/**
- * Test updating an existing account with new characters.
- */
-void
-StorageTest::testUpdAccount1(void)
-{
- LOG("StorageTest::testUpdAccount1()");
-
- Storage& myStorage = Storage::instance(mStorageName);
-
- CPPUNIT_ASSERT(myStorage.isOpen());
-
- // get an existing account.
- const std::string name("frodo");
- Account* account = myStorage.getAccount(name);
-
- // create new characters.
- RawStatistics stats = {1, 1, 1, 1, 1, 1};
-
- BeingPtr b1(new Being("sam1", GENDER_MALE, 0, 0, stats));
- BeingPtr b2(new Being("sam2", GENDER_MALE, 0, 0, stats));
-
- // add the characters to the account.
- account->addCharacter(b1);
- account->addCharacter(b2);
-
- // update the database.
- myStorage.flush();
-
- // check the database.
- Checks checks;
- checks.set(CHK_DEFAULT_ACCOUNTS);
- checks.set(CHK_CHARACTERS_1);
- checkDb(checks);
-}
-
-
-/**
- * Test updating an existing account with a new password and new
- * character stats.
- */
-void
-StorageTest::testUpdAccount2(void)
-{
- LOG("StorageTest::testUpdAccount2()");
-
- Storage& myStorage = Storage::instance(mStorageName);
-
- CPPUNIT_ASSERT(myStorage.isOpen());
-
- // get an existing account.
- const std::string name("frodo");
- Account* account = myStorage.getAccount(name);
-
- // create new characters.
- RawStatistics stats = {1, 1, 1, 1, 1, 1};
-
- BeingPtr b1(new Being("sam1", GENDER_MALE, 0, 0, stats));
- BeingPtr b2(new Being("sam2", GENDER_MALE, 0, 0, stats));
-
- // add the characters to the account.
- account->addCharacter(b1);
- account->addCharacter(b2);
-
- // update the database.
- myStorage.flush();
-
- // change the account password.
- using tmwserv::utils::Cipher;
- const std::string newPassword(Cipher::instance().md5("myprecious"));
- account->setPassword(newPassword);
-
- // change the strength of the first character.
- b1->setStrength(10);
-
- // update the database.
- myStorage.flush();
-
- // check the database.
- Checks checks;
- checks.set(CHK_DEFAULT_ACCOUNTS);
- checks.set(CHK_CHARACTERS_UPDATE_1);
- checkDb(checks);
-}
-
-
-/**
- * Test deleting an account that exists in the database but not
- * loaded yet in memory.
- */
-void
-StorageTest::testDelAccount1(void)
-{
- LOG("StorageTest::testDelAccount1()");
-
- Storage& myStorage = Storage::instance(mStorageName);
-
- CPPUNIT_ASSERT(myStorage.isOpen());
-
- myStorage.delAccount("frodo");
-
- // check the database.
- Checks checks;
- checks.set(CHK_1ST_ACCOUNT_DELETED);
- checkDb(checks);
-}
-
-
-/**
- * Test deleting an account that was added to the storage but not
- * yet persisted.
- */
-void
-StorageTest::testDelAccount2(void)
-{
- LOG("StorageTest::testDelAccount2()");
-
- Storage& myStorage = Storage::instance(mStorageName);
-
- CPPUNIT_ASSERT(myStorage.isOpen());
-
- // prepare new account.
- RawStatistics stats = {1, 1, 1, 1, 1, 1};
-
- BeingPtr b1(new Being("sam1", GENDER_MALE, 0, 0, stats));
- BeingPtr b2(new Being("sam2", GENDER_MALE, 0, 0, stats));
- Beings characters;
- characters.push_back(b1);
- characters.push_back(b2);
-
- const std::string sam("sam");
- AccountPtr acc(new Account(sam, sam, "sam@domain", characters));
-
- myStorage.addAccount(acc);
- myStorage.delAccount(sam);
-
- // nothing should be added to the database.
- myStorage.flush();
-
- // check the database.
- Checks checks;
- checks.set(CHK_DEFAULT_ACCOUNTS);
- checkDb(checks);
-}
-
-
-/**
- * Test deleting an account that exists in the database and loaded
- * in memory.
- */
-void
-StorageTest::testDelAccount3(void)
-{
- LOG("StorageTest::testDelAccount3()");
-
- Storage& myStorage = Storage::instance(mStorageName);
-
- CPPUNIT_ASSERT(myStorage.isOpen());
-
- // get an existing account.
- const std::string name("frodo");
- Account* account = myStorage.getAccount(name);
-
- CPPUNIT_ASSERT_EQUAL(name, account->getName());
-
- // update the account with new characters so that we can check
- // that delAccount() is doing more than just deleting the tmw_accounts
- // table.
- RawStatistics stats = {1, 1, 1, 1, 1, 1};
- BeingPtr b1(new Being("sam1", GENDER_MALE, 0, 0, stats));
- BeingPtr b2(new Being("sam2", GENDER_MALE, 0, 0, stats));
- account->addCharacter(b1);
- account->addCharacter(b2);
-
- // flush() so that the new characters are stored in the database
- // before we delete the account.
- myStorage.flush();
-
- // we won't check if the tmw_characters contains the newly added
- // characters as it has been tested in testUpdAccount2().
-
- // finally, we are ready to delete the account.
- myStorage.delAccount(name);
- myStorage.flush();
-
- // check the database.
- Checks checks;
- checks.set(CHK_1ST_ACCOUNT_DELETED);
- checks.set(CHK_NO_CHARACTERS_1);
- checkDb(checks);
-}
-
-
-/**
- * Test deleting an account that does not exist.
- */
-void
-StorageTest::testDelAccount4(void)
-{
- LOG("StorageTest::testDelAccount4()");
-
- Storage& myStorage = Storage::instance(mStorageName);
-
- CPPUNIT_ASSERT(myStorage.isOpen());
-
- // nothing should happen nor modified in the database.
- myStorage.delAccount("xxx");
- myStorage.flush();
-
- // check the database.
- Checks checks;
- checks.set(CHK_DEFAULT_ACCOUNTS);
- checkDb(checks);
-}
-
-
-/**
- * Test deleting twice an account that exists in the database and
- * loaded in memory.
- */
-void
-StorageTest::testDelAccount5(void)
-{
- LOG("StorageTest::testDelAccount5()");
-
- Storage& myStorage = Storage::instance(mStorageName);
-
- CPPUNIT_ASSERT(myStorage.isOpen());
-
- // get an existing account.
- const std::string name("frodo");
- Account* account = myStorage.getAccount(name);
-
- CPPUNIT_ASSERT_EQUAL(name, account->getName());
-
- myStorage.delAccount(name);
- myStorage.flush();
-
- // delete it again, no error should occur.
- myStorage.delAccount(name);
- myStorage.flush();
-
- // check the database.
- Checks checks;
- checks.set(CHK_1ST_ACCOUNT_DELETED);
- checkDb(checks);
-}
-
-
-/**
- * Initialize the storage.
- */
-void
-StorageTest::initStorage(void)
-{
-#if defined (MYSQL_SUPPORT) || defined (POSTGRESQL_SUPPORT) || \
- defined (SQLITE_SUPPORT)
-
- // we are using a database to persist the data from the storage.
-
- using namespace tmwserv::dal;
-
- // insert initial data using the data provider directly.
- // we must avoid using the APIs from Storage here as it's the purpose
- // of these tests.
- std::auto_ptr<DataProvider> db(DataProviderFactory::createDataProvider());
-
- try {
-#ifdef SQLITE_SUPPORT
- std::string dbFile(mStorageName);
- dbFile += ".db";
-
- // ensure that the file does not exist before the tests begin.
- if (PHYSFS_exists(dbFile.c_str())) {
- if (PHYSFS_delete(dbFile.c_str()) == 0) {
- CPPUNIT_FAIL(PHYSFS_getLastError());
- }
- }
-
- db->connect(dbFile, mStorageUser, mStorageUserPassword);
-#else
- db->connect(mStorageName, mStorageUser, mStorageUserPassword);
-#endif
-
- // drop the tables.
- dropTable(db, MAPS_TBL_NAME);
- dropTable(db, ACCOUNTS_TBL_NAME);
- dropTable(db, CHARACTERS_TBL_NAME);
- dropTable(db, ITEMS_TBL_NAME);
- dropTable(db, WORLD_ITEMS_TBL_NAME);
- dropTable(db, INVENTORIES_TBL_NAME);
-
- // recreate the tables.
- db->execSql(SQL_MAPS_TABLE);
- db->execSql(SQL_ACCOUNTS_TABLE);
- db->execSql(SQL_CHARACTERS_TABLE);
- db->execSql(SQL_ITEMS_TABLE);
- db->execSql(SQL_WORLD_ITEMS_TABLE);
- db->execSql(SQL_INVENTORIES_TABLE);
-
- // populate the tables.
- insertAccount(db, "frodo");
- insertAccount(db, "merry");
- insertAccount(db, "pippin");
-
- db->disconnect();
- }
- catch (const DbConnectionFailure& e) {
- CPPUNIT_FAIL(e.what());
- }
- catch (const DbSqlQueryExecFailure& e) {
- CPPUNIT_FAIL(e.what());
- }
- catch (const DbDisconnectionFailure& e) {
- CPPUNIT_FAIL(e.what());
- }
- catch (const std::exception& e) {
- CPPUNIT_FAIL(e.what());
- }
- catch (...) {
- CPPUNIT_FAIL("unexpected exception");
- }
-#endif
-}
-
-
-/**
- * Clean the storage.
- */
-void
-StorageTest::cleanStorage(void)
-{
-#if defined (MYSQL_SUPPORT) || defined (POSTGRESQL_SUPPORT) || \
- defined (SQLITE_SUPPORT)
-
- // we are using a database to persist the data from the storage.
-
- using namespace tmwserv::dal;
-
- std::auto_ptr<DataProvider> db(DataProviderFactory::createDataProvider());
-
- try {
-#ifdef SQLITE_SUPPORT
- std::string dbFile(mStorageName);
- dbFile += ".db";
-
- // ensure that the file does not exist before the tests begin.
- if (PHYSFS_exists(dbFile.c_str())) {
- if (PHYSFS_delete(dbFile.c_str()) == 0) {
- CPPUNIT_FAIL(PHYSFS_getLastError());
- }
- }
-#else
- db->connect(mStorageName, mStorageUser, mStorageUserPassword);
-
- // drop the tables.
- dropTable(db, MAPS_TBL_NAME);
- dropTable(db, ACCOUNTS_TBL_NAME);
- dropTable(db, CHARACTERS_TBL_NAME);
- dropTable(db, ITEMS_TBL_NAME);
- dropTable(db, WORLD_ITEMS_TBL_NAME);
- dropTable(db, INVENTORIES_TBL_NAME);
-
- db->disconnect();
-#endif
- }
- catch (const DbConnectionFailure& e) {
- CPPUNIT_FAIL(e.what());
- }
- catch (const DbSqlQueryExecFailure& e) {
- CPPUNIT_FAIL(e.what());
- }
- catch (const DbDisconnectionFailure& e) {
- CPPUNIT_FAIL(e.what());
- }
- catch (const std::exception& e) {
- CPPUNIT_FAIL(e.what());
- }
- catch (...) {
- CPPUNIT_FAIL("unexpected exception");
- }
-#endif
-}
-
-
-/**
- * Drop a table.
- */
-void
-StorageTest::dropTable(std::auto_ptr<DataProvider>& db,
- const std::string& name)
-{
- try {
- std::string sql("drop table ");
- sql += name;
- sql += ";";
- db->execSql(sql);
- }
- catch (const DbSqlQueryExecFailure& e) {
- // ignore, the table may not exist.
- }
-}
-
-
-/**
- * Insert a new account.
- */
-void
-StorageTest::insertAccount(std::auto_ptr<DataProvider>& db,
- const std::string& name)
-{
- std::ostringstream sql;
-
- // the password will be identical to the name.
-
- sql << "insert into " << ACCOUNTS_TBL_NAME << " values "
- << "(null, '" << name << "', '"
- << tmwserv::utils::Cipher::instance().md5(name) << "', '"
- << name << "@domain', 0, 0);";
-
- db->execSql(sql.str());
-}
-
-
-/**
- * Check the state of the database.
- */
-void
-StorageTest::checkDb(const Checks& what)
-{
-#if defined (MYSQL_SUPPORT) || defined (POSTGRESQL_SUPPORT) || \
- defined (SQLITE_SUPPORT)
-
- using namespace tmwserv::dal;
-
- std::auto_ptr<DataProvider> db(DataProviderFactory::createDataProvider());
-
- try {
-#ifdef SQLITE_SUPPORT
- std::string dbFile(mStorageName);
- dbFile += ".db";
- db->connect(dbFile, mStorageUser, mStorageUserPassword);
-#else
- db->connect(mStorageName, mStorageUser, mStorageUserPassword);
-#endif
-
- std::string sql("select * from ");
- sql += ACCOUNTS_TBL_NAME;
- sql += ";";
- const RecordSet& rs = db->execSql(sql);
-
- if (what[CHK_DEFAULT_ACCOUNTS]) {
- CPPUNIT_ASSERT(rs.rows() == 3);
-
- const std::string frodo("frodo");
- const std::string merry("merry");
- const std::string pippin("pippin");
-
- CPPUNIT_ASSERT_EQUAL(frodo, rs(0, "username"));
- CPPUNIT_ASSERT_EQUAL(merry, rs(1, "username"));
- CPPUNIT_ASSERT_EQUAL(pippin, rs(2, "username"));
- }
-
- if (what[CHK_1ST_ACCOUNT_DELETED]) {
- CPPUNIT_ASSERT(rs.rows() == 2);
-
- const std::string merry("merry");
- const std::string pippin("pippin");
-
- CPPUNIT_ASSERT_EQUAL(merry, rs(0, "username"));
- CPPUNIT_ASSERT_EQUAL(pippin, rs(1, "username"));
- }
-
- if (what[CHK_NEW_ADDED_ACCOUNT]) {
- CPPUNIT_ASSERT(rs.rows() == 4);
-
- const std::string frodo("frodo");
- const std::string merry("merry");
- const std::string pippin("pippin");
- const std::string sam("sam");
-
- CPPUNIT_ASSERT_EQUAL(frodo, rs(0, "username"));
- CPPUNIT_ASSERT_EQUAL(merry, rs(1, "username"));
- CPPUNIT_ASSERT_EQUAL(pippin, rs(2, "username"));
- CPPUNIT_ASSERT_EQUAL(sam, rs(3, "username"));
- }
-
- if (what[CHK_CHARACTERS_1] || what[CHK_CHARACTERS_UPDATE_1] ||
- what[CHK_NO_CHARACTERS_1])
- {
- sql = "select * from ";
- sql += CHARACTERS_TBL_NAME;
- sql += " where user_id = 1;";
- }
- else if (what[CHK_CHARACTERS_4]) {
- sql = "select * from ";
- sql += CHARACTERS_TBL_NAME;
- sql += " where user_id = 4;";
- }
-
- db->execSql(sql);
-
- if (what[CHK_CHARACTERS_1] || what[CHK_CHARACTERS_4] ||
- what[CHK_CHARACTERS_UPDATE_1])
- {
- CPPUNIT_ASSERT(rs.rows() == 2);
-
- const std::string sam1("sam1");
- const std::string sam2("sam2");
-
- CPPUNIT_ASSERT_EQUAL(sam1, rs(0, "name"));
- CPPUNIT_ASSERT_EQUAL(sam2, rs(1, "name"));
-
- if (what[CHK_CHARACTERS_UPDATE_1]) {
- string_to<unsigned short> toUshort;
- CPPUNIT_ASSERT_EQUAL((unsigned short) 10,
- toUshort(rs(0, "str")));
- }
- }
- else if (what[CHK_NO_CHARACTERS_1]) {
- CPPUNIT_ASSERT(rs.rows() == 0);
- }
-
- db->disconnect();
- }
- catch (const DbConnectionFailure& e) {
- CPPUNIT_FAIL(e.what());
- }
- catch (const DbSqlQueryExecFailure& e) {
- CPPUNIT_FAIL(e.what());
- }
- catch (const DbDisconnectionFailure& e) {
- CPPUNIT_FAIL(e.what());
- }
- catch (const std::exception& e) {
- CPPUNIT_FAIL(e.what());
- }
- catch (...) {
- CPPUNIT_FAIL("unexpected exception");
- }
-#endif
-}
diff --git a/src/tests/teststorage.h b/src/tests/teststorage.h
deleted file mode 100644
index 1d3b75da..00000000
--- a/src/tests/teststorage.h
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * The Mana World Server
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or any later version.
- *
- * The Mana World is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with The Mana World; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-
-#ifndef _TMWSERV_TEST_STORAGE_H_
-#define _TMWSERV_TEST_STORAGE_H_
-
-
-#include <bitset>
-#include <vector>
-
-#include <cppunit/extensions/HelperMacros.h>
-
-#include "../dal/dataproviderfactory.h"
-
-
-/**
- * Requirements:
- * - if using MySQL or PostgreSQL as backends, then make sure that a user
- * named 'guest' with the password 'guest' has enough privileges to
- * create tables and populate them in a database named 'tmwteststorage'
- * prior to running the teststorage unit tests.
- */
-
-
-using namespace tmwserv::dal;
-
-
-/**
- * Unit test for the Storage class.
- */
-class StorageTest: public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(StorageTest);
-
- // add tests to the test suite.
- CPPUNIT_TEST(testGetAccount1);
- CPPUNIT_TEST(testGetAccount2);
- CPPUNIT_TEST(testAddAccount1);
- CPPUNIT_TEST(testAddAccount2);
- CPPUNIT_TEST(testUpdAccount1);
- CPPUNIT_TEST(testUpdAccount2);
- CPPUNIT_TEST(testDelAccount1);
- CPPUNIT_TEST(testDelAccount2);
- CPPUNIT_TEST(testDelAccount3);
- CPPUNIT_TEST(testDelAccount4);
- CPPUNIT_TEST(testDelAccount5);
-
- CPPUNIT_TEST_SUITE_END();
-
-
- public:
- /**
- * Set up fixtures.
- */
- void
- setUp(void);
-
-
- /**
- * Tear down fixtures.
- */
- void
- tearDown(void);
-
-
- /**
- * Fetch an existing account from the database.
- */
- void
- testGetAccount1(void);
-
-
- /**
- * Fetch an unexisting account from the database.
- */
- void
- testGetAccount2(void);
-
-
- /**
- * Test passing a null pointer to addAcccount().
- */
- void
- testAddAccount1(void);
-
-
- /**
- * Test adding a new account.
- */
- void
- testAddAccount2(void);
-
-
- /**
- * Test updating an existing account with new characters.
- */
- void
- testUpdAccount1(void);
-
-
- /**
- * Test updating an existing account with a new password and new
- * character stats.
- */
- void
- testUpdAccount2(void);
-
-
- /**
- * Test deleting an account that exists in the database but not
- * loaded yet in memory.
- */
- void
- testDelAccount1(void);
-
-
- /**
- * Test deleting an account that was added to the storage but not
- * yet persisted.
- */
- void
- testDelAccount2(void);
-
-
- /**
- * Test deleting an account that exists in the database and loaded
- * in memory.
- */
- void
- testDelAccount3(void);
-
-
- /**
- * Test deleting an account that does not exist.
- */
- void
- testDelAccount4(void);
-
-
- /**
- * Test deleting twice an account that exists in the database and
- * loaded in memory.
- */
- void
- testDelAccount5(void);
-
-
- private:
- /**
- * Initialize the storage.
- */
- void
- initStorage(void);
-
-
- /**
- * Clean the storage.
- */
- void
- cleanStorage(void);
-
-
- /**
- * Drop a table.
- *
- * @param db the database.
- * @param name the table name.
- */
- void
- dropTable(std::auto_ptr<DataProvider>& db,
- const std::string& name);
-
-
- /**
- * Insert a new account.
- *
- * @param db the database.
- * @param name the user name.
- */
- void
- insertAccount(std::auto_ptr<DataProvider>&,
- const std::string& name);
-
-
- /**
- * Enumeration type for the bits.
- * Each bit represents a particular check.
- */
- enum CheckValues {
- CHK_DEFAULT_ACCOUNTS,
- CHK_1ST_ACCOUNT_DELETED,
- CHK_NEW_ADDED_ACCOUNT,
- CHK_CHARACTERS_1,
- CHK_CHARACTERS_4,
- CHK_CHARACTERS_UPDATE_1,
- CHK_NO_CHARACTERS_1,
- NUM_CHECKS
- };
-
-
- /**
- * Type definition for the checks.
- */
- typedef std::bitset<NUM_CHECKS> Checks;
-
-
- /**
- * Check the state of the database.
- *
- * @param what bitmask that contains information about what to check.
- */
- void
- checkDb(const Checks& what);
-
-
- private:
- static std::string mStorageName; /**< name of the storage */
- static std::string mStorageUser; /**< storage user */
- static std::string mStorageUserPassword; /**< user password */
-};
-
-
-#endif // _TMWSERV_TEST_STORAGE_H_
diff --git a/tmwserv.cbp b/tmwserv.cbp
deleted file mode 100644
index 3fff6a53..00000000
--- a/tmwserv.cbp
+++ /dev/null
@@ -1,478 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE CodeBlocks_project_file>
-<CodeBlocks_project_file>
- <FileVersion major="1" minor="1"/>
- <Project>
- <Option title="tmwserv"/>
- <Option makefile="Makefile"/>
- <Option makefile_is_custom="0"/>
- <Option compiler="0"/>
- <Build>
- <Target title="default">
- <Option output="tmwserv.exe"/>
- <Option working_dir="."/>
- <Option object_output="src\obj"/>
- <Option deps_output=".deps"/>
- <Option type="1"/>
- <Option compiler="0"/>
- <Option projectResourceIncludeDirsRelation="1"/>
- </Target>
- </Build>
- <Compiler>
- <Add option="-DSQLITE_SUPPORT"/>
- </Compiler>
- <Linker>
- <Add option="-mconsole"/>
- <Add option="-mwindows"/>
- <Add library="mingw32"/>
- <Add library="enet"/>
- <Add library="ws2_32"/>
- <Add library="sqlite3"/>
- <Add library="xml2"/>
- <Add library="physfs"/>
- <Add library="pthreadGC2"/>
- <Add library="z"/>
- <Add library="winmm"/>
- </Linker>
- <Unit filename="src\account.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\account.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\accountclient.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\accountclient.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\accounthandler.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\accounthandler.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\being.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\being.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\chatchannel.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\chatchannel.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\chatchannelmanager.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\chatchannelmanager.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\chathandler.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\chathandler.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\configuration.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\configuration.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\connectionhandler.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\connectionhandler.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\controller.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\controller.h">
- <Option compilerVar=""/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\dal\dalexcept.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\dal\dataprovider.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\dal\dataprovider.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\dal\dataproviderfactory.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\dal\dataproviderfactory.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\dal\recordset.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\dal\recordset.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\dal\sqlitedataprovider.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\dal\sqlitedataprovider.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\dalstorage.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\dalstorage.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\dalstoragesql.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\debug.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\debug.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\defines.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\gameclient.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\gameclient.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\gamehandler.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\gamehandler.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\inventory.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\inventory.h">
- <Option compilerVar=""/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\item.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\item.h">
- <Option compilerVar=""/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\itemhandler.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\itemhandler.h">
- <Option compilerVar=""/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\main.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\map.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\map.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\mapcomposite.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\mapcomposite.h">
- <Option compilerVar=""/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\mapmanager.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\mapmanager.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\mapreader.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\mapreader.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\messagein.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\messagein.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\messageout.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\messageout.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\netcomputer.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\netcomputer.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\object.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\object.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\player.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\player.h">
- <Option compilerVar=""/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\resourcemanager.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\resourcemanager.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\script.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\script.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\skill.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\skill.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\state.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\state.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\storage.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\storage.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\utils\base64.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\utils\base64.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\utils\countedptr.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\utils\functors.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\utils\logger.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\utils\logger.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\utils\singleton.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\utils\stringfilter.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\utils\stringfilter.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\utils\timer.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\utils\timer.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\utils\wingettimeofday.cpp">
- <Option compilerVar="CPP"/>
- <Option target="default"/>
- </Unit>
- <Unit filename="src\utils\wingettimeofday.h">
- <Option compilerVar="CPP"/>
- <Option compile="0"/>
- <Option link="0"/>
- <Option target="default"/>
- </Unit>
- </Project>
-</CodeBlocks_project_file>
diff --git a/tmwserv.dev b/tmwserv.dev
deleted file mode 100644
index b43b4d20..00000000
--- a/tmwserv.dev
+++ /dev/null
@@ -1,919 +0,0 @@
-[Project]
-FileName=tmwserv.dev
-Name=tmwserv
-UnitCount=87
-Type=1
-Ver=1
-ObjFiles=
-Includes=
-Libs=
-PrivateResource=tmwserv_private.rc
-ResourceIncludes=
-MakeIncludes=
-Compiler=_@@_
-CppCompiler=-DSQLITE_SUPPORT_@@_
-Linker=-lmingw32_@@_-lenet_@@_-lws2_32_@@_-lsqlite3_@@_-lxml2_@@_-lphysfs_@@_-lpthreadGC2_@@_-lz_@@_-mconsole_@@_-mwindows_@@_-lwinmm_@@_
-IsCpp=1
-Icon=
-ExeOutput=
-ObjectOutput=src\obj
-OverrideOutput=0
-OverrideOutputName=tmwserv.exe
-HostApplication=
-Folders=dal,utils
-CommandLine=
-UseCustomMakefile=0
-CustomMakefile=
-IncludeVersionInfo=1
-SupportXPThemes=0
-CompilerSet=0
-CompilerSettings=0000000000001001000100
-
-[Unit3]
-FileName=src\dal\dataprovider.h
-CompileCpp=1
-Folder=dal
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit14]
-FileName=src\accounthandler.h
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit15]
-FileName=src\connectionhandler.cpp
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[VersionInfo]
-Major=0
-Minor=0
-Release=1
-Build=0
-LanguageID=2057
-CharsetID=1252
-CompanyName=The Mana World Development Team
-FileVersion=0.0.1
-FileDescription=The Mana World Server
-InternalName=tmwserv
-LegalCopyright=(C) 2004-2005
-LegalTrademarks=
-OriginalFilename=tmwserv.exe
-ProductName=tmwserv
-ProductVersion=1st milestone
-AutoIncBuildNr=0
-
-[Unit24]
-FileName=src\messageout.cpp
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit26]
-FileName=src\netcomputer.cpp
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit27]
-FileName=src\netcomputer.h
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit28]
-FileName=src\object.cpp
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit29]
-FileName=src\object.h
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit31]
-FileName=src\script.h
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit30]
-FileName=src\script.cpp
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit34]
-FileName=src\storage.cpp
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit36]
-FileName=src\dalstorage.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit32]
-FileName=src\skill.cpp
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit33]
-FileName=src\skill.h
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit37]
-FileName=src\account.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit38]
-FileName=src\account.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit40]
-FileName=src\utils\functors.h
-CompileCpp=1
-Folder=utils
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit41]
-FileName=src\being.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit21]
-FileName=src\main.cpp
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit2]
-FileName=src\dal\dataprovider.cpp
-CompileCpp=1
-Folder=dal
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit4]
-FileName=src\dal\dataproviderfactory.cpp
-CompileCpp=1
-Folder=dal
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit5]
-FileName=src\dal\dataproviderfactory.h
-CompileCpp=1
-Folder=dal
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit6]
-FileName=src\dal\recordset.cpp
-CompileCpp=1
-Folder=dal
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit8]
-FileName=src\dal\sqlitedataprovider.cpp
-CompileCpp=1
-Folder=dal
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit9]
-FileName=src\dal\sqlitedataprovider.h
-CompileCpp=1
-Folder=dal
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit12]
-FileName=src\utils\singleton.h
-CompileCpp=1
-Folder=utils
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit13]
-FileName=src\accounthandler.cpp
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit18]
-FileName=src\debug.cpp
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit19]
-FileName=src\debug.h
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit20]
-FileName=src\defines.h
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit35]
-FileName=src\storage.h
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit42]
-FileName=src\being.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit43]
-FileName=src\configuration.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit44]
-FileName=src\configuration.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit47]
-FileName=src\chathandler.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit49]
-FileName=src\map.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit54]
-FileName=src\utils\base64.cpp
-CompileCpp=1
-Folder=utils
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit55]
-FileName=src\state.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit56]
-FileName=src\state.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit58]
-FileName=src\gamehandler.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit59]
-FileName=src\mapmanager.h
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit61]
-FileName=src\mapreader.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit62]
-FileName=src\utils\stringfilter.cpp
-CompileCpp=1
-Folder=utils
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit64]
-FileName=src\chatchannelmanager.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit65]
-FileName=src\chatchannelmanager.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit7]
-FileName=src\dal\recordset.h
-CompileCpp=1
-Folder=dal
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit1]
-FileName=src\dal\dalexcept.h
-CompileCpp=1
-Folder=dal
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit11]
-FileName=src\utils\logger.h
-CompileCpp=1
-Folder=utils
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit17]
-FileName=src\dalstorage.cpp
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit22]
-FileName=src\messagein.cpp
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit23]
-FileName=src\messagein.h
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit25]
-FileName=src\messageout.h
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit46]
-FileName=src\chathandler.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit16]
-FileName=src\connectionhandler.h
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit63]
-FileName=src\utils\stringfilter.h
-CompileCpp=1
-Folder=utils
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit50]
-FileName=src\map.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit51]
-FileName=src\mapreader.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit52]
-FileName=src\resourcemanager.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit57]
-FileName=src\gamehandler.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit66]
-FileName=src\chatchannel.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit67]
-FileName=src\chatchannel.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit68]
-FileName=src\utils\wingettimeofday.h
-CompileCpp=1
-Folder=utils
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit69]
-FileName=src\utils\timer.cpp
-CompileCpp=1
-Folder=utils
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit71]
-FileName=src\utils\wingettimeofday.cpp
-CompileCpp=1
-Folder=utils
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit39]
-FileName=src\utils\countedptr.h
-CompileCpp=1
-Folder=utils
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit74]
-FileName=src\gameclient.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit10]
-FileName=src\utils\logger.cpp
-CompileCpp=1
-Folder=utils
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit45]
-FileName=src\dalstoragesql.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit72]
-FileName=src\accountclient.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit73]
-FileName=src\accountclient.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit70]
-FileName=src\utils\timer.h
-CompileCpp=1
-Folder=utils
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit75]
-FileName=src\gameclient.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit76]
-FileName=src\player.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit53]
-FileName=src\utils\base64.h
-CompileCpp=1
-Folder=utils
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit79]
-FileName=src\controller.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit80]
-FileName=src\mapcomposite.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit81]
-FileName=src\inventory.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit77]
-FileName=src\player.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit78]
-FileName=src\controller.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit48]
-FileName=src\resourcemanager.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit60]
-FileName=src\mapmanager.cpp
-CompileCpp=1
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit82]
-FileName=src\inventory.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit83]
-FileName=src\item.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit84]
-FileName=src\item.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit85]
-FileName=src\itemhandler.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit86]
-FileName=src\itemhandler.h
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit87]
-FileName=src\mapcomposite.cpp
-CompileCpp=1
-Folder=tmwserv
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-