summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/Makefile4
-rw-r--r--src/map/atcommand.c2
-rw-r--r--src/map/charsave.c523
-rw-r--r--src/map/charsave.h21
-rw-r--r--src/map/chrif.c26
-rw-r--r--src/map/chrif.h2
-rw-r--r--src/map/map.c110
-rw-r--r--src/map/map.h9
-rw-r--r--src/map/mercenary.c1
-rw-r--r--src/map/npc.c5
-rw-r--r--src/map/npc_chat.c4
11 files changed, 30 insertions, 677 deletions
diff --git a/src/map/Makefile b/src/map/Makefile
index 5f9f122e8..10af86c8f 100644
--- a/src/map/Makefile
+++ b/src/map/Makefile
@@ -24,8 +24,7 @@ OBJECTS = obj/map.o obj/chrif.o obj/clif.o obj/pc.o obj/status.o obj/npc.o \
obj/npc_chat.o obj/chat.o obj/path.o obj/itemdb.o obj/mob.o obj/script.o \
obj/storage.o obj/skill.o obj/atcommand.o obj/charcommand.o obj/battle.o \
obj/intif.o obj/trade.o obj/party.o obj/vending.o obj/guild.o obj/pet.o \
- obj/log.o obj/mail.o obj/charsave.o obj/date.o obj/irc.o obj/unit.o \
- obj/mercenary.o \
+ obj/log.o obj/mail.o obj/date.o obj/irc.o obj/unit.o obj/mercenary.o \
$(COMMON_OBJ)
map-server: $(OBJECTS:obj/%=txtobj/%)
@@ -99,7 +98,6 @@ sqlobj/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mo
sqlobj/mail.o: mail.c mail.h $(COMMON_H)
sqlobj/log.o: log.c log.h map.h $(COMMON_H)
sqlobj/charcommand.o: charcommand.c charcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H)
-sqlobj/charsave.o: charsave.c charsave.h $(COMMON_H)
sqlobj/date.o: date.c date.h $(COMMON_H)
sqlobj/irc.o: irc.c irc.h map.h pc.h $(COMMON_H)
sqlobj/unit.o: unit.c unit.h $(COMMON_H)
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 72664aa1c..25a6b4e19 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -2913,6 +2913,8 @@ int atcommand_gm(const int fd, struct map_session_data* sd, const char* command,
return 0;
}
+// helper function, used in foreach calls to stop auto-attack timers
+// parameter: '0' - everyone, 'id' - only those attacking someone with that id
static int atcommand_stopattack(struct block_list *bl,va_list ap)
{
struct unit_data *ud = unit_bl2ud(bl);
diff --git a/src/map/charsave.c b/src/map/charsave.c
deleted file mode 100644
index 13724cffd..000000000
--- a/src/map/charsave.c
+++ /dev/null
@@ -1,523 +0,0 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "../common/cbasetypes.h"
-#include "../common/core.h"
-#include "../common/socket.h"
-#include "../common/timer.h"
-#include "../common/nullpo.h"
-#include "../common/mmo.h"
-#include "../common/strlib.h"
-#include "../common/showmsg.h"
-#include "../common/malloc.h"
-
-#include "charsave.h"
-#include "map.h"
-
-#ifndef TXT_ONLY
-
-struct mmo_charstatus *charsave_loadchar(int charid){
- int i,j, friends;
- struct mmo_charstatus *c;
- char *str_p;
- double exp;
- friends = 0;
-
- c = (struct mmo_charstatus *)aCalloc(1,sizeof(struct mmo_charstatus));
-
- if(charid <= 0){
- ShowError("charsave_loadchar() charid <= 0! (%d)", charid);
- aFree(c);
- return NULL;
- }
- // add homun_id [albator]
- //Tested, Mysql 4.1.9+ has no problems with the long query, the buf is 65k big and the sql server needs for it 0.00009 secs on an athlon xp 2400+ WinXP (1GB Mem) .. [Sirius]
- sprintf(tmp_sql, "SELECT `char_id`,`account_id`,`char_num`,`name`,`class`,`base_level`,`job_level`,`base_exp`,`job_exp`,`zeny`, `str`,`agi`,`vit`,`int`,`dex`,`luk`, `max_hp`,`hp`,`max_sp`,`sp`,`status_point`,`skill_point`, `option`,`karma`,`manner`,`party_id`,`guild_id`,`pet_id`,`hair`,`hair_color`, `clothes_color`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom`, `last_map`,`last_x`,`last_y`,`save_map`,`save_x`,`save_y`, `partner_id`, `father`, `mother`, `child`, `fame`, `homun_id` FROM `char` WHERE `char_id` = '%d'", charid);
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- aFree(c);
- return NULL;
- }
-
- charsql_res = mysql_store_result(&charsql_handle);
- if(mysql_num_rows(charsql_res) <= 0){
- ShowWarning("charsave_loadchar() -> CHARACTER NOT FOUND! (id: %d)\n", charid);
- mysql_free_result(charsql_res);
- aFree(c);
- return NULL;
- }
-
- //fetch data
- charsql_row = mysql_fetch_row(charsql_res);
-
- //fill with data
- c->char_id = charid;
- c->account_id = atoi(charsql_row[1]);
- c->char_num = atoi(charsql_row[2]);
- strcpy(c->name, charsql_row[3]);
- c->class_ = atoi(charsql_row[4]);
- c->base_level = atoi(charsql_row[5]);
- c->job_level = atoi(charsql_row[6]);
- exp = atof(charsql_row[7]);
- c->base_exp = (unsigned int)cap_value(exp,0,UINT_MAX);
- exp = atof(charsql_row[8]);
- c->job_exp = (unsigned int)cap_value(exp,0,UINT_MAX);
- c->zeny = atoi(charsql_row[9]);
- c->str = atoi(charsql_row[10]);
- c->agi = atoi(charsql_row[11]);
- c->vit = atoi(charsql_row[12]);
- c->int_ = atoi(charsql_row[13]);
- c->dex = atoi(charsql_row[14]);
- c->luk = atoi(charsql_row[15]);
- c->max_hp = atoi(charsql_row[16]);
- c->hp = atoi(charsql_row[17]);
- c->max_sp = atoi(charsql_row[18]);
- c->sp = atoi(charsql_row[19]);
- c->status_point = atoi(charsql_row[20]) > USHRT_MAX? USHRT_MAX : atoi(charsql_row[20]);
- c->skill_point = atoi(charsql_row[21]) > USHRT_MAX? USHRT_MAX : atoi(charsql_row[21]);
- c->option = atoi(charsql_row[22]);
- c->karma = atoi(charsql_row[23]);
- c->manner = atoi(charsql_row[24]);
- c->party_id = atoi(charsql_row[25]);
- c->guild_id = atoi(charsql_row[26]);
- c->pet_id = atoi(charsql_row[27]);
- c->hair = atoi(charsql_row[28]);
- c->hair_color = atoi(charsql_row[29]);
- c->clothes_color = atoi(charsql_row[30]);
- c->weapon = atoi(charsql_row[31]);
- c->shield = atoi(charsql_row[32]);
- c->head_top = atoi(charsql_row[33]);
- c->head_mid = atoi(charsql_row[34]);
- c->head_bottom = atoi(charsql_row[35]);
- c->last_point.map = mapindex_name2id(charsql_row[36]);
- c->last_point.x = atoi(charsql_row[37]);
- c->last_point.y = atoi(charsql_row[38]);
- c->save_point.map = mapindex_name2id(charsql_row[39]);
- c->save_point.x = atoi(charsql_row[40]);
- c->save_point.y = atoi(charsql_row[41]);
- c->partner_id = atoi(charsql_row[42]);
- c->father = atoi(charsql_row[43]);
- c->mother = atoi(charsql_row[44]);
- c->child = atoi(charsql_row[45]);
- c->fame = atoi(charsql_row[46]);
- c->hom_id = atoi(charsql_row[47]); // albator
-
- mysql_free_result(charsql_res);
-
- //Check for '0' Savepoint / LastPoint
- if (c->last_point.x == 0 || c->last_point.y == 0 || c->last_point.map == 0){
- c->last_point.map = mapindex_name2id(MAP_PRONTERA);
- c->last_point.x = 100;
- c->last_point.y = 100;
- }
-
- if (c->save_point.x == 0 || c->save_point.y == 0 || c->save_point.map == 0){
- c->save_point.map = mapindex_name2id(MAP_PRONTERA);
- c->save_point.x = 100;
- c->save_point.y = 100;
- }
-
-
- //read the memo points
- sprintf(tmp_sql, "SELECT `memo_id`, `char_id`, `map`, `x`, `y` FROM `memo` WHERE `char_id` = '%d' ORDER BY `memo_id`", charid);
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- aFree(c);
- return NULL;
- }
-
- charsql_res = mysql_store_result(&charsql_handle);
- if(charsql_res){
- for(i = 0; (charsql_row = mysql_fetch_row(charsql_res)); i++){
- c->memo_point[i].map = mapindex_name2id(charsql_row[2]);
- c->memo_point[i].x = atoi(charsql_row[3]);
- c->memo_point[i].y = atoi(charsql_row[4]);
- }
- mysql_free_result(charsql_res);
- }
-
- //read inventory...
- str_p = tmp_sql;
- str_p += sprintf(str_p, "SELECT `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`");
- for (i = 0; i < MAX_SLOTS; i++)
- str_p += sprintf(str_p, ", `card%d`", i);
- str_p += sprintf(str_p, " FROM `inventory` WHERE `char_id` = '%d'", charid);
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- aFree(c);
- return NULL;
- }
-
- charsql_res = mysql_store_result(&charsql_handle);
- if(charsql_res){
- for(i = 0; (charsql_row = mysql_fetch_row(charsql_res)); i++){
- //c->inventory[i].id = atoi(charsql_row[0]);
- c->inventory[i].nameid = atoi(charsql_row[0]);
- c->inventory[i].amount = atoi(charsql_row[1]);
- c->inventory[i].equip = atoi(charsql_row[2]);
- c->inventory[i].identify = atoi(charsql_row[3]);
- c->inventory[i].refine = atoi(charsql_row[4]);
- c->inventory[i].attribute = atoi(charsql_row[5]);
- for (j = 0; j < MAX_SLOTS; j++)
- c->inventory[i].card[j] = atoi(charsql_row[6+j]);
- }
- mysql_free_result(charsql_res);
- }
-
-
- //cart inventory ..
- str_p = tmp_sql;
- str_p += sprintf(str_p, "SELECT `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`");
- for (i = 0; i < MAX_SLOTS; i++)
- str_p += sprintf(str_p, ", `card%d`", i);
- str_p += sprintf(str_p, " FROM `cart_inventory` WHERE `char_id` = '%d'", charid);
-
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- aFree(c);
- return NULL;
- }
-
- charsql_res = mysql_store_result(&charsql_handle);
- if(charsql_res){
- for(i = 0; (charsql_row = mysql_fetch_row(charsql_res)); i++){
- //c->cart[i].id = atoi(charsql_row[0]);
- c->cart[i].nameid = atoi(charsql_row[0]);
- c->cart[i].amount = atoi(charsql_row[1]);
- c->cart[i].equip = atoi(charsql_row[2]);
- c->cart[i].identify = atoi(charsql_row[3]);
- c->cart[i].refine = atoi(charsql_row[4]);
- c->cart[i].attribute = atoi(charsql_row[5]);
- for (j = 0; j < MAX_SLOTS; j++)
- c->cart[i].card[j] = atoi(charsql_row[6+j]);
- }
- mysql_free_result(charsql_res);
- }
-
-
- //Skills...
- sprintf(tmp_sql, "SELECT `char_id`, `id`, `lv` FROM `skill` WHERE `char_id` = '%d'", charid);
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- aFree(c);
- return NULL;
- }
-
- charsql_res = mysql_store_result(&charsql_handle);
- if(charsql_res){
- while((charsql_row = mysql_fetch_row(charsql_res))){
- i = atoi(charsql_row[1]);
- c->skill[i].id = i;
- c->skill[i].lv = atoi(charsql_row[2]);
- }
- mysql_free_result(charsql_res);
- }
-/* Reg values are handled by the char server.
- //Global REG
- sprintf(tmp_sql, "SELECT `char_id`, `str`, `value` FROM `global_reg_value` WHERE `type` = '3' AND `char_id` = '%d'", charid);
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- aFree(c);
- return NULL;
- }
-
- charsql_res = mysql_store_result(&charsql_handle);
- if(charsql_res){
- for(i = 0; (charsql_row = mysql_fetch_row(charsql_res)); i++){
- strcpy(c->global_reg[i].str, charsql_row[1]);
- strcpy(c->global_reg[i].value, charsql_row[2]);
- }
- mysql_free_result(charsql_res);
- c->global_reg_num = i;
- }
-*/
-
- //Shamelessly stolen from its_sparky (ie: thanks) and then assimilated by [Skotlex]
- //Friend list
- sprintf(tmp_sql, "SELECT f.friend_account, f.friend_id, c.name FROM friends f LEFT JOIN `char` c ON f.friend_account=c.account_id AND f.friend_id=c.char_id WHERE f.char_id='%d'", charid);
-
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- sql_res = NULL; //To avoid trying to read data.
- }
- else
- sql_res = mysql_store_result(&charsql_handle);
-
- if(sql_res)
- {
- for(i = 0; (sql_row = mysql_fetch_row(sql_res)) && i<MAX_FRIENDS; i++)
- {
- if (sql_row[2] != NULL)
- {
- c->friends[i].account_id = atoi(sql_row[0]);
- c->friends[i].char_id = atoi(sql_row[1]);
- strncpy(c->friends[i].name, sql_row[2], NAME_LENGTH-1); //The -1 is to avoid losing the ending \0 [Skotlex]
- }
- }
- mysql_free_result(sql_res);
- }
-
- ShowInfo("charsql_loadchar(): loading of '%d' (%s) complete.\n", charid, c->name);
- return c;
-}
-
-int charsave_savechar(int charid, struct mmo_charstatus *c){
- int i,j;
- char *str_p;
-// char tmp_str[64];
-// char tmp_str2[512];
- //First save the 'char'
- sprintf(tmp_sql ,"UPDATE `char` SET `class`='%d', `base_level`='%d', `job_level`='%d',"
- "`base_exp`='%u', `job_exp`='%u', `zeny`='%d',"
- "`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%d',`skill_point`='%d',"
- "`str`='%d',`agi`='%d',`vit`='%d',`int`='%d',`dex`='%d',`luk`='%d',"
- "`option`='%d',`karma`='%d',`manner`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',"
- "`hair`='%d',`hair_color`='%d',`clothes_color`='%d',`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d',"
- "`last_map`='%s',`last_x`='%d',`last_y`='%d',`save_map`='%s',`save_x`='%d',`save_y`='%d',"
- "`partner_id`='%d', `father`='%d', `mother`='%d', `child`='%d', `fame`='%d', `homun_id`='%d'"
- "WHERE `account_id`='%d' AND `char_id` = '%d'",
- c->class_, c->base_level, c->job_level,
- c->base_exp, c->job_exp, c->zeny,
- c->max_hp, c->hp, c->max_sp, c->sp, c->status_point, c->skill_point,
- c->str, c->agi, c->vit, c->int_, c->dex, c->luk,
- c->option, c->karma, c->manner, c->party_id, c->guild_id, c->pet_id,
- c->hair, c->hair_color, c->clothes_color,
- c->weapon, c->shield, c->head_top, c->head_mid, c->head_bottom,
- mapindex_id2name(c->last_point.map), c->last_point.x, c->last_point.y,
- mapindex_id2name(c->save_point.map), c->save_point.x, c->save_point.y, c->partner_id, c->father, c->mother,
- c->child, c->fame, c->hom_id, c->account_id, c->char_id
- );
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
-
-
- //Save the inventory
- sprintf(tmp_sql, "DELETE FROM `inventory` WHERE `char_id` = '%d'", charid);
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
- for(i = 0; i < MAX_INVENTORY; i++){
- if(c->inventory[i].nameid > 0){
- str_p = tmp_sql;
- str_p += sprintf(str_p, "INSERT INTO `inventory` (`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`");
- for (j = 0; j < MAX_SLOTS; j++)
- str_p += sprintf(str_p, ", `card%d`", j);
-
- str_p += sprintf(str_p, ") VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d'",
- charid, c->inventory[i].nameid, c->inventory[i].amount, c->inventory[i].equip,
- c->inventory[i].identify, c->inventory[i].refine, c->inventory[i].attribute);
-
- for (j = 0; j < MAX_SLOTS; j++)
- str_p += sprintf(str_p, ", '%d'", c->inventory[i].card[j]);
-
- strcat(tmp_sql,")");
-
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
- }
- }
-
- //Save the cart
- sprintf(tmp_sql, "DELETE FROM `cart_inventory` WHERE `char_id` = '%d'", charid);
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
- for(i = 0; i < MAX_CART; i++){
- if(c->cart[i].nameid > 0){
- str_p = tmp_sql;
- str_p += sprintf(str_p, "INSERT INTO `cart_inventory` (`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`");
- for (j = 0; j < MAX_SLOTS; j++)
- str_p += sprintf(str_p, ", `card%d`", j);
-
- str_p += sprintf(str_p, ") VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d'",
- charid, c->cart[i].nameid, c->cart[i].amount, c->cart[i].equip,
- c->cart[i].identify, c->cart[i].refine, c->cart[i].attribute);
-
- for (j = 0; j < MAX_SLOTS; j++)
- str_p += sprintf(str_p, ", '%d'", c->cart[i].card[j]);
-
- strcat(tmp_sql,")");
-
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
- }
- }
-
-
- //Save memo points
- sprintf(tmp_sql, "DELETE FROM `memo` WHERE `char_id` = '%d'", charid);
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
- for(i = 0; i < MAX_MEMOPOINTS; i++){
- if(c->memo_point[i].map && c->memo_point[i].x > 0 && c->memo_point[i].y > 0){
- sprintf(tmp_sql, "INSERT INTO `memo` ( `char_id`, `map`, `x`, `y` ) VALUES ('%d', '%s', '%d', '%d')", charid, mapindex_id2name(c->memo_point[i].map), c->memo_point[i].x, c->memo_point[i].y);
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
- }
- }
-
-
- //Save skills
- sprintf(tmp_sql, "DELETE FROM `skill` WHERE `char_id` = '%d'", charid);
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
- for(i = 0; i < MAX_SKILL; i++){
- if(c->skill[i].id > 0){
- sprintf(tmp_sql, "INSERT INTO `skill` (`char_id`, `id`, `lv`) VALUES ('%d', '%d', '%d')", charid, c->skill[i].id, c->skill[i].lv);
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
- }
- }
-
-
-/* Reg values are handled by the char server.
- //global_reg_value saving
- sprintf(tmp_sql, "DELETE FROM `global_reg_value` WHERE `type`=3 AND `char_id` = '%d'", charid);
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
- for(i = 0; i < c->global_reg_num; i++){
- if(c->global_reg[i].str){
- if(c->global_reg[i].value){
- //jstrescapecpy(tmp_str, c->global_reg[i].str);
- sprintf(tmp_sql, "INSERT INTO `global_reg_value` (`char_id`, `str`, `value`) VALUES ('%d', '%s', '%s')", charid, jstrescapecpy(tmp_str,c->global_reg[i].str), jstrescapecpy(tmp_str2,c->global_reg[i].value));
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
- }
- }
- }
-*/
-
- //friendlist saving
- sprintf(tmp_sql, "DELETE FROM `friends` WHERE `char_id` = '%d'", charid);
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
- for(i = 0; i < MAX_FRIENDS; i++){
- if(c->friends[i].char_id > 0){
- sprintf(tmp_sql, "INSERT INTO `friends` (`char_id`, `friend_account`, `friend_id`) VALUES ('%d','%d','%d')", charid, c->friends[i].account_id, c->friends[i].char_id);
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
- }
- }
-
- ShowInfo("charsql_savechar(): saving of '%d' (%s) complete.\n", charid, c->name);
- return 0;
-}
-
-int charsave_load_scdata(int account_id, int char_id)
-{ //Loads character's sc_data
- struct map_session_data *sd;
-
- sd = map_id2sd(account_id);
- if (!sd)
- {
- ShowError("charsave_load_scdata: Player of AID %d not found!\n", account_id);
- return -1;
- }
- if (sd->status.char_id != char_id)
- {
- ShowError("charsave_load_scdata: Receiving data for account %d, char id does not matches (%d != %d)!\n", account_id, sd->status.char_id, char_id);
- return -1;
- }
- sprintf(tmp_sql, "SELECT `type`, `tick`, `val1`, `val2`, `val3`, `val4` FROM `sc_data`"
- "WHERE `account_id`='%d' AND `char_id`='%d'", account_id, char_id);
-
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- return -1;
- }
-
- sql_res = mysql_store_result(&charsql_handle);
- if(sql_res)
- {
- while ((sql_row = mysql_fetch_row(sql_res)))
- {
- if (atoi(sql_row[1]) < 1)
- { //Protection against invalid tick values. [Skotlex]
- ShowWarning("charsave_load_scdata: Received invalid duration (%d ms) for status change %d (character %s)\n", atoi(sql_row[1]), sd->status.name);
- continue;
- }
-
- status_change_start(&sd->bl, atoi(sql_row[0]), 10000, atoi(sql_row[2]), atoi(sql_row[3]),
- atoi(sql_row[4]), atoi(sql_row[5]), atoi(sql_row[1]), 15);
- }
- }
-
- //Once loaded, sc_data must be disposed.
- sprintf(tmp_sql, "DELETE FROM `sc_data` WHERE `account_id`='%d' AND `char_id`='%d'", account_id, char_id);
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
- return 0;
-}
-
-void charsave_save_scdata(int account_id, int char_id, struct status_change* sc_data, int max_sc)
-{ //Saves character's sc_data.
- int i,count =0;
- struct TimerData *timer;
- unsigned int tick = gettick();
- char *p = tmp_sql;
-
- p += sprintf(p, "INSERT INTO `sc_data` (`account_id`, `char_id`, `type`, `tick`, `val1`, `val2`, `val3`, `val4`) VALUES ");
-
- for(i = 0; i < max_sc; i++)
- {
- if (sc_data->data[i].timer == -1)
- continue;
- timer = get_timer(sc_data->data[i].timer);
- if (timer == NULL || timer->func != status_change_timer || DIFF_TICK(timer->tick,tick) < 0)
- continue;
-
- p += sprintf(p, " ('%d','%d','%hu','%d','%d','%d','%d','%d'),", account_id, char_id,
- i, DIFF_TICK(timer->tick,tick), sc_data->data[i].val1, sc_data->data[i].val2, sc_data->data[i].val3, sc_data->data[i].val4);
-
- count++;
- }
- if (count > 0)
- {
- *--p = '\0'; //Remove the trailing comma.
- if(mysql_query(&charsql_handle, tmp_sql)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
- }
- ShowInfo("charsql_save_scdata(): saved %d status changes of '%d:%d'.\n", count, account_id, char_id);
- return;
-}
-#endif
diff --git a/src/map/charsave.h b/src/map/charsave.h
deleted file mode 100644
index 5734ebf58..000000000
--- a/src/map/charsave.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
-
-#ifndef _CHARSAVE_H_
-#define _CHARSAVE_H_
-
-#include "status.h"
-
-#ifndef TXT_ONLY
- int charsave_loadHomunculus(int hom_id, struct homun_data *p);
- int charsave_saveHomunculus(struct homun_data *hd);
- int charsave_saveHomunculusSkills(struct homun_data *hd);
- int charsave_deleteHomunculus(struct homun_data *hd);
-
- struct mmo_charstatus *charsave_loadchar(int charid);
- int charsave_savechar(int charid, struct mmo_charstatus *c);
- int charsave_load_scdata(int account_id, int char_id);
- void charsave_save_scdata(int account_id, int char_id, struct status_change* sc_data, int max_sc);
-#endif
-
-#endif /* _CHARSAVE_H_ */
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 87517f40c..09565b608 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -23,9 +23,7 @@
#include "pc.h"
#include "status.h"
#include "mercenary.h"
-#ifndef TXT_ONLY
-#include "charsave.h"
-#endif
+
//Updated table (only doc^^) [Sirius]
//Used Packets: U->2af8
//Free Packets: F->2af8
@@ -210,16 +208,7 @@ int chrif_save(struct map_session_data *sd, int flag)
intif_saveregistry(sd, 2); //Save account regs
if (sd->state.reg_dirty&1)
intif_saveregistry(sd, 1); //Save account2 regs
-#ifndef TXT_ONLY
- if(charsave_method){ //New 'Local' save
- charsave_savechar(sd->status.char_id, &sd->status);
- if (flag) //Character final saved.
- sd->state.finalsave = 1;
- if (flag == 1)
- chrif_char_offline(sd); //Tell char server that character went offline.
- return 0;
- }
-#endif
+
WFIFOHEAD(char_fd, sizeof(sd->status) + 13);
WFIFOW(char_fd,0) = 0x2b01;
WFIFOW(char_fd,2) = sizeof(sd->status) + 13;
@@ -458,10 +447,6 @@ int chrif_sendmapack(int fd)
int chrif_scdata_request(int account_id, int char_id)
{
#ifdef ENABLE_SC_SAVING
-#ifndef TXT_ONLY
- if (charsave_method)
- return charsave_load_scdata(account_id, char_id);
-#endif
chrif_check(-1);
WFIFOHEAD(char_fd, 10);
@@ -1231,13 +1216,6 @@ int chrif_save_scdata(struct map_session_data *sd)
if (sd->state.finalsave) //Character was already saved?
return -1;
-#ifndef TXT_ONLY
- if(charsave_method) //New 'Local' save
- {
- charsave_save_scdata(sd->status.account_id, sd->status.char_id, &sd->sc, MAX_STATUSCHANGE);
- return 0;
- }
-#endif
chrif_check(-1);
tick = gettick();
diff --git a/src/map/chrif.h b/src/map/chrif.h
index a94591cd4..a80543d1a 100644
--- a/src/map/chrif.h
+++ b/src/map/chrif.h
@@ -48,8 +48,6 @@ int chrif_changesex(int id, int sex);
int chrif_chardisconnect(struct map_session_data *sd);
int check_connect_char_server(int tid, unsigned int tick, int id, int data);
-int chrif_pcauthok(int fd);
-
int do_final_chrif(void);
int do_init_chrif(void);
diff --git a/src/map/map.c b/src/map/map.c
index dfdda95b7..a438731de 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -46,65 +46,53 @@
#include "log.h"
-#include "charsave.h"
-
#include "irc.h"
#ifndef TXT_ONLY
-#include "mail.h" // mail system [Valaris]
+#include "mail.h"
-MYSQL mmysql_handle;
-MYSQL_RES* sql_res ;
-MYSQL_ROW sql_row ;
char tmp_sql[65535]="";
-
-MYSQL logmysql_handle; //For the log database - fix by [Maeki]
-MYSQL_RES* logsql_res ;
-MYSQL_ROW logsql_row ;
-
-MYSQL mail_handle; // mail system [Valaris]
-MYSQL_RES* mail_res ;
-MYSQL_ROW mail_row ;
+char default_codepage[32] = "";
int map_server_port = 3306;
char map_server_ip[16] = "127.0.0.1";
char map_server_id[32] = "ragnarok";
char map_server_pw[32] = "ragnarok";
char map_server_db[32] = "ragnarok";
-char default_codepage[32] = ""; //Feature by irmin.
-int db_use_sqldbs = 0;
+MYSQL mmysql_handle;
+MYSQL_RES* sql_res;
+MYSQL_ROW sql_row;
+int db_use_sqldbs = 0;
char item_db_db[32] = "item_db";
char item_db2_db[32] = "item_db2";
char mob_db_db[32] = "mob_db";
char mob_db2_db[32] = "mob_db2";
-int log_db_port = 3306;
+char char_db[32] = "char";
+
+// log database
char log_db_ip[16] = "127.0.0.1";
+int log_db_port = 3306;
char log_db_id[32] = "ragnarok";
char log_db_pw[32] = "ragnarok";
char log_db[32] = "log";
+MYSQL logmysql_handle;
+MYSQL_RES* logsql_res;
+MYSQL_ROW logsql_row;
-int mail_server_port = 3306;
+// mail system
+int mail_server_enable = 0;
char mail_server_ip[16] = "127.0.0.1";
+int mail_server_port = 3306;
char mail_server_id[32] = "ragnarok";
char mail_server_pw[32] = "ragnarok";
char mail_server_db[32] = "ragnarok";
-int mail_server_enable = 0;
-
-char char_db[32] = "char";
-
char mail_db[32] = "mail";
-
-char charsql_host[40] = "localhost";
-int charsql_port = 3306;
-char charsql_user[32] = "ragnarok";
-char charsql_pass[32] = "eAthena";
-char charsql_db[40] = "ragnarok";
-MYSQL charsql_handle;
-MYSQL_RES* charsql_res;
-MYSQL_ROW charsql_row;
+MYSQL mail_handle;
+MYSQL_RES* mail_res;
+MYSQL_ROW mail_row;
#endif /* not TXT_ONLY */
@@ -150,7 +138,6 @@ int map_port=0;
int autosave_interval = DEFAULT_AUTOSAVE_INTERVAL;
int minsave_interval = 100;
int save_settings = 0xFFFF;
-int charsave_method = 0; //Default 'OLD' Save method (SQL ONLY!) [Sirius]
int agit_flag = 0;
int night_flag = 0; // 0=day, 1=night [Yor]
@@ -182,7 +169,7 @@ void map_setusers(int fd)
WFIFOHEAD(fd, 2);
map_users = RFIFOL(fd,2);
- // send some anser
+ // send some answer
WFIFOW(fd,0) = 0x2718;
WFIFOSET(fd,2);
}
@@ -1721,15 +1708,6 @@ int map_quit(struct map_session_data *sd) {
sd->st = NULL;
sd->npc_id = 0;
}
-#ifndef TXT_ONLY
- if(charsave_method)
- { //Let player be free'd on closing the connection.
- idb_remove(pc_db,sd->status.account_id);
- if (!(sd->fd && session[sd->fd]->session_data == sd))
- aFree(sd); //In case player was not attached to session.
- return 0;
- }
-#endif
if(sd->fd)
{ //Player will be free'd on save-ack. [Skotlex]
if (session[sd->fd])
@@ -2754,9 +2732,8 @@ int map_config_read(char *cfgName) {
} else if(strcmpi(w1,"stdout_with_ansisequence")==0){
stdout_with_ansisequence = config_switch(w2);
} else if(strcmpi(w1,"console_silent")==0){
- msg_silent = 0; //To always allow the next line to show up.
- ShowInfo("Console Silent Setting: %d\n", atoi(w2));
msg_silent = atoi(w2);
+ ShowInfo("Console Silent Setting: %d\n", msg_silent);
} else if (strcmpi(w1, "userid")==0){
chrif_setuserid(w2);
} else if (strcmpi(w1, "passwd") == 0) {
@@ -2854,8 +2831,6 @@ int inter_config_read(char *cfgName)
strcpy(main_chat_nick, w2);
#ifndef TXT_ONLY
- } else if(strcmpi(w1,"charsave_method")==0){
- charsave_method = atoi(w2); //New char saving method.
} else if(strcmpi(w1,"item_db_db")==0){
strcpy(item_db_db,w2);
} else if(strcmpi(w1,"mob_db_db")==0){
@@ -2882,16 +2857,6 @@ int inter_config_read(char *cfgName)
} else if(strcmpi(w1,"use_sql_db")==0){
db_use_sqldbs = battle_config_switch(w2);
ShowStatus ("Using SQL dbs: %s\n",w2);
- }else if(strcmpi(w1, "char_server_ip") == 0){
- strcpy(charsql_host, w2);
- }else if(strcmpi(w1, "char_server_port") == 0){
- charsql_port = atoi(w2);
- }else if(strcmpi(w1, "char_server_id") == 0){
- strcpy(charsql_user, w2);
- }else if(strcmpi(w1, "char_server_pw") == 0){
- strcpy(charsql_pass, w2);
- }else if(strcmpi(w1, "char_server_db") == 0){
- strcpy(charsql_db, w2);
} else if(strcmpi(w1,"log_db")==0) {
strcpy(log_db, w2);
} else if(strcmpi(w1,"log_db_ip")==0) {
@@ -3184,8 +3149,6 @@ void do_final(void) {
#ifndef TXT_ONLY
map_sql_close();
- if(charsave_method)
- charsql_db_init(0); //Connecting to chardb
#endif /* not TXT_ONLY */
ShowStatus("Successfully terminated.\n");
}
@@ -3331,8 +3294,6 @@ int do_init(int argc, char *argv[]) {
charid_db = db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_RELEASE_DATA,sizeof(int));
#ifndef TXT_ONLY
map_sql_init();
- if(charsave_method)
- charsql_db_init(1); //Connecting to chardb
#endif /* not TXT_ONLY */
map_readallmaps();
@@ -3399,32 +3360,3 @@ int compare_item(struct item *a, struct item *b) {
}
return 0;
}
-
-#ifndef TXT_ONLY
-int charsql_db_init(int method){
-
- if(method == 1){ //'INIT / START'
- ShowInfo("Connecting to 'character' Database... ");
- mysql_init(&charsql_handle);
-
- if(!mysql_real_connect(&charsql_handle, charsql_host, charsql_user, charsql_pass, charsql_db, charsql_port, (char *)NULL, 0)){
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- exit(1);
- }else{
- printf("success.\n");
- if( strlen(default_codepage) > 0 ) {
- sprintf( tmp_sql, "SET NAMES %s", default_codepage );
- if (mysql_query(&charsql_handle, tmp_sql)) {
- ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
- }
- }
- }else if(method == 0){ //'FINAL' / Shutdown
- ShowInfo("Closing 'character' Database connection ... ");
- mysql_close(&charsql_handle);
- printf("done.\n");
- }
- return 0;
-}
-#endif
diff --git a/src/map/map.h b/src/map/map.h
index 4ce73972e..87ac38711 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -1431,9 +1431,6 @@ void map_spawnmobs(int); // [Wizputer]
void map_removemobs(int); // [Wizputer]
void do_reconnect_map(void); //Invoked on map-char reconnection [Skotlex]
-//Added for own save method
-int charsql_db_init(int method);
-
extern char *INTER_CONF_NAME;
extern char *LOG_CONF_NAME;
extern char *MAP_CONF_NAME;
@@ -1444,8 +1441,6 @@ extern char *SCRIPT_CONF_NAME;
extern char *MSG_CONF_NAME;
extern char *GRF_PATH_FILENAME;
-
-extern int charsave_method; //needed ..
extern char *map_server_dns;
#ifndef TXT_ONLY
@@ -1464,10 +1459,6 @@ extern MYSQL mmysql_handle;
extern MYSQL_RES* sql_res ;
extern MYSQL_ROW sql_row ;
-extern MYSQL charsql_handle;
-extern MYSQL_RES* charsql_res;
-extern MYSQL_ROW charsql_row;
-
extern MYSQL logmysql_handle;
extern MYSQL_RES* logsql_res ;
extern MYSQL_ROW logsql_row ;
diff --git a/src/map/mercenary.c b/src/map/mercenary.c
index a11373032..80e471ddc 100644
--- a/src/map/mercenary.c
+++ b/src/map/mercenary.c
@@ -36,7 +36,6 @@
#include "unit.h"
#include "mercenary.h"
-#include "charsave.h"
//Better equiprobability than rand()% [orn]
#define rand(a, b) a+(int) ((float)(b-a+1)*rand()/(RAND_MAX+1.0))
diff --git a/src/map/npc.c b/src/map/npc.c
index cb104c11b..edeb6d8d4 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -2345,9 +2345,8 @@ static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, char *fir
script_free_vars( &oldscript->script_vars );
aFree( oldscript->script_buf );
user_db->remove(user_db,str2key(p));
- strdb_put(user_db, p, script);
- } else
- strdb_put(user_db, p, script);
+ }
+ strdb_put(user_db, p, script);
// もう使わないのでバッファ解放
aFree(srcbuf);
diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c
index e77c93020..9cee26f8e 100644
--- a/src/map/npc_chat.c
+++ b/src/map/npc_chat.c
@@ -369,7 +369,7 @@ int npc_chat_sub(struct block_list *bl, va_list ap)
{
struct npc_data *nd = (struct npc_data *)bl;
struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
- unsigned char *msg;
+ char *msg;
int len, pos, i;
struct map_session_data *sd;
struct npc_label_list *lst;
@@ -379,7 +379,7 @@ int npc_chat_sub(struct block_list *bl, va_list ap)
if (npcParse == NULL || npcParse->active_ == NULL)
return 0;
- msg = va_arg(ap,unsigned char*);
+ msg = va_arg(ap,char*);
len = va_arg(ap,int);
sd = va_arg(ap,struct map_session_data *);