summaryrefslogtreecommitdiff
path: root/src/char_sql
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-05-23 21:23:36 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-05-23 21:23:36 +0000
commitf6bcd12cd633717e9e503bb453c85955e29cd519 (patch)
tree49225d619843accadf26532263f615392da5b8a2 /src/char_sql
parent9b9305b6b1a1a004c2ef909404daa705e956a5de (diff)
downloadhercules-f6bcd12cd633717e9e503bb453c85955e29cd519.tar.gz
hercules-f6bcd12cd633717e9e503bb453c85955e29cd519.tar.bz2
hercules-f6bcd12cd633717e9e503bb453c85955e29cd519.tar.xz
hercules-f6bcd12cd633717e9e503bb453c85955e29cd519.zip
- Added new flag to skill_castnodex.txt, to allow per-skill tweaking of cast time and delay reducibility by item scripts (cards and such)
- Fixed Martyr's Reckoning never triggering for gms with all skills - Added MO_TRIPLEATTACK and RG_SNATCHER to @skillall's skill filter - Made gm_skill_unconditional bypass skill blocking (guild timer, etc) - Reverted the weird delay_dependon_agi thing (r8923, r9055, r9059) - Changed a few memsets to strncpy (reading past buffer is a bad idea) - Sped up some memset operations (multiples of 4 are faster) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10613 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql')
-rw-r--r--src/char_sql/char.c54
-rw-r--r--src/char_sql/int_guild.c9
-rw-r--r--src/char_sql/int_homun.c2
-rw-r--r--src/char_sql/int_party.c5
-rw-r--r--src/char_sql/int_pet.c11
5 files changed, 36 insertions, 45 deletions
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index eeca0209f..a1fdc8835 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -70,13 +70,12 @@ int lowest_gm_level = 1;
char *SQL_CONF_NAME = "conf/inter_athena.conf";
-struct mmo_map_server{
- uint32 ip;
- uint16 port;
- int users;
- unsigned short map[MAX_MAP_PER_SERVER];
+struct mmo_map_server {
+ uint32 ip;
+ uint16 port;
+ int users;
+ unsigned short map[MAX_MAP_PER_SERVER];
} server[MAX_MAP_SERVERS];
-
int server_fd[MAX_MAP_SERVERS];
int login_fd, char_fd;
@@ -93,10 +92,11 @@ char bind_ip_str[128];
uint32 bind_ip = INADDR_ANY;
uint16 char_port = 6121;
int char_maintenance = 0;
-int char_new;
-int char_new_display;
+int char_new = 1;
+int char_new_display = 0;
int name_ignoring_case = 0; // Allow or not identical name for characters but with a different case by [Yor]
int char_name_option = 0; // Option to know which letters/symbols are authorised in the name of a character (0: all, 1: only those in char_name_letters, 2: all EXCEPT those in char_name_letters) by [Yor]
+char unknown_char_name[NAME_LENGTH] = "Unknown";
char char_name_letters[1024] = ""; // list of letters/symbols used to authorise or not a name of a character. by [Yor]
//The following are characters that are trimmed regardless because they cause confusion and problems on the servers. [Skotlex]
#define TRIM_CHARS "\032\t\x0A\x0D "
@@ -116,7 +116,6 @@ struct _subnet {
int subnet_count = 0;
-char unknown_char_name[NAME_LENGTH] = "Unknown";
char db_path[1024]="db";
//These are used to aid the map server in identifying valid clients. [Skotlex]
@@ -185,8 +184,6 @@ struct online_char_data {
struct dbt *online_char_db; //Holds all online characters.
-static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, int data);
-
static void * create_online_char_data(DBKey key, va_list args)
{
struct online_char_data* character;
@@ -199,6 +196,8 @@ static void * create_online_char_data(DBKey key, va_list args)
return character;
}
+static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, int data);
+
//-------------------------------------------------
// Set Character online/offline [Wizputer]
//-------------------------------------------------
@@ -206,7 +205,7 @@ static void * create_online_char_data(DBKey key, va_list args)
void set_char_online(int map_id, int char_id, int account_id)
{
struct online_char_data* character;
-
+
if ( char_id != 99 ) {
sprintf(tmp_sql, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d'",char_db,char_id);
if (mysql_query(&mysql_handle, tmp_sql)) {
@@ -1732,7 +1731,6 @@ int parse_tologin(int fd)
struct char_session_data *sd;
// only login-server can have an access to here.
// so, if it isn't the login-server, we disconnect the session.
- //session eof check!
if(fd != login_fd)
set_eof(fd);
if(session[fd]->eof) {
@@ -2597,7 +2595,7 @@ int parse_frommap(int fd)
auth_fifo_pos++;
WFIFOHEAD(fd,7);
WFIFOW(fd,0) = 0x2b03;
- WFIFOL(fd,2) = RFIFOL(fd, 2);
+ WFIFOL(fd,2) = RFIFOL(fd,2);
WFIFOB(fd,6) = 0;
WFIFOSET(fd,7);
RFIFOSKIP(fd,18);
@@ -2968,8 +2966,8 @@ int parse_frommap(int fd)
break;
default:
- // inter server - packet
{
+ // inter server - packet
int r = inter_parse_frommap(fd);
if (r == 1) break; // processed
if (r == 2) return 0; // need more packet
@@ -2981,6 +2979,7 @@ int parse_frommap(int fd)
}
} // switch
} // while
+
return 0;
}
@@ -3223,7 +3222,7 @@ int parse_char(int fd)
char_dat.last_point.map = j;
}
{
- //Send player to map.
+ //Send player to map
uint32 subnet_map_ip;
char map_name[MAP_NAME_LENGTH_EXT];
snprintf(map_name, MAP_NAME_LENGTH_EXT, "%s.gat", mapindex_id2name(char_dat.last_point.map));
@@ -3252,11 +3251,11 @@ int parse_char(int fd)
//Send NEW auth packet [Kevin]
if ((map_fd = server_fd[i]) < 1 || session[map_fd] == NULL)
{
- WFIFOHEAD(fd,3);
ShowError("parse_char: Attempting to write to invalid session %d! Map Server #%d disconnected.\n", map_fd, i);
server_fd[i] = -1;
memset(&server[i], 0, sizeof(struct mmo_map_server));
//Send server closed.
+ WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x81;
WFIFOB(fd,2) = 1; // 01 = Server closed
WFIFOSET(fd,3);
@@ -3276,7 +3275,7 @@ int parse_char(int fd)
set_char_online(i, auth_fifo[auth_fifo_pos].char_id, auth_fifo[auth_fifo_pos].account_id);
auth_fifo_pos++;
- break;
+ break;
case 0x67: // make new
FIFOSD_CHECK(37);
@@ -3317,7 +3316,7 @@ int parse_char(int fd)
break;
}
}
- break;
+ break;
case 0x68: // delete char
FIFOSD_CHECK(46);
@@ -3394,8 +3393,8 @@ int parse_char(int fd)
/* Char successfully deleted.*/
WFIFOW(fd,0) = 0x6f;
WFIFOSET(fd,2);
- break;
}
+ break;
case 0x2af8: // login as map-server
if (RFIFOREST(fd) < 60)
@@ -3441,14 +3440,14 @@ int parse_char(int fd)
WFIFOW(fd,2) = len;
WFIFOSET(fd,len);
}
- break;
}
+ break;
case 0x187: // Alive?
if (RFIFOREST(fd) < 6)
return 0;
RFIFOSKIP(fd, 6);
- break;
+ break;
case 0x7530: // Athena info get
{
@@ -3465,6 +3464,7 @@ int parse_char(int fd)
RFIFOSKIP(fd,2);
return 0;
}
+
case 0x7532: // disconnect(default also disconnect)
default:
set_eof(fd);
@@ -3588,7 +3588,7 @@ static int send_accounts_tologin_sub(DBKey key, void* data, va_list ap)
return 0; //This is an error that shouldn't happen....
if(character->server > -1) {
WFIFOHEAD(login_fd,8+count*4);
- WFIFOL(login_fd,8+(*i)*4) =character->account_id;
+ WFIFOL(login_fd,8+(*i)*4) = character->account_id;
(*i)++;
return 1;
}
@@ -3613,7 +3613,7 @@ int send_accounts_tologin(int tid, unsigned int tick, int id, int data)
int check_connect_login_server(int tid, unsigned int tick, int id, int data)
{
- if (login_fd > 0 && session[login_fd] != NULL)
+ if (login_fd > 0 && session[login_fd] != NULL)
return 0;
ShowInfo("Attempt to connect to login-server...\n");
@@ -3811,7 +3811,7 @@ void sql_config_read(const char *cfgName)
}
fclose(fp);
- ShowInfo("done reading %s.\n", cfgName);
+ ShowInfo("Done reading %s.\n", cfgName);
}
#ifndef TXT_SQL_CONVERT
@@ -4098,11 +4098,11 @@ int do_init(int argc, char **argv)
ShowStatus("Defaulting to %s as our IP address\n", ip_str);
if (!login_ip) {
strcpy(login_ip_str, ip_str);
- login_ip = ntohl(inet_addr(login_ip_str));
+ login_ip = str2ip(login_ip_str);
}
if (!char_ip) {
strcpy(char_ip_str, ip_str);
- char_ip = ntohl(inet_addr(char_ip_str));
+ char_ip = str2ip(char_ip_str);
}
}
diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c
index 4bbe15b0c..3ecaec839 100644
--- a/src/char_sql/int_guild.c
+++ b/src/char_sql/int_guild.c
@@ -1,9 +1,6 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
-// original code from athena
-// SQL conversion by hack
-
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@@ -1439,8 +1436,8 @@ int mapif_parse_GuildLeave(int fd,int guild_id,int account_id,int char_id,int fl
}
// Save the expulsion
g->expulsion[j].account_id=account_id;
- memcpy(g->expulsion[j].acc,"dummy",NAME_LENGTH-1);
- memcpy(g->expulsion[j].name,g->member[i].name,NAME_LENGTH-1);
+ strncpy(g->expulsion[j].acc,"dummy",NAME_LENGTH);
+ memcpy(g->expulsion[j].name,g->member[i].name,NAME_LENGTH);
memcpy(g->expulsion[j].mes,mes,40);
}
@@ -1860,7 +1857,7 @@ int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2,
if(g[i]->alliance[j].guild_id==0)
{
g[i]->alliance[j].guild_id=g[1-i]->guild_id;
- memcpy(g[i]->alliance[j].name,g[1-i]->name,NAME_LENGTH-1);
+ memcpy(g[i]->alliance[j].name,g[1-i]->name,NAME_LENGTH);
// Set alliance type
g[i]->alliance[j].opposition = flag&GUILD_ALLIANCE_TYPE_MASK;
break;
diff --git a/src/char_sql/int_homun.c b/src/char_sql/int_homun.c
index acee4f823..42f4ef225 100644
--- a/src/char_sql/int_homun.c
+++ b/src/char_sql/int_homun.c
@@ -147,7 +147,7 @@ int mapif_load_homunculus(int fd){
homun_pt->hom_id = RFIFOL(fd,6) ; //RFIFOL(fd,2);
homun_pt->class_ = atoi(sql_row[2]);
- memcpy(homun_pt->name, sql_row[3],NAME_LENGTH-1);
+ strncpy(homun_pt->name, sql_row[3], NAME_LENGTH);
homun_pt->char_id = atoi(sql_row[1]);
homun_pt->level = atoi(sql_row[4]);
homun_pt->exp = atoi(sql_row[5]);
diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c
index 181050e4e..3f3a88de1 100644
--- a/src/char_sql/int_party.c
+++ b/src/char_sql/int_party.c
@@ -1,9 +1,6 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
-// original code from athena
-// SQL conversion by hack
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -247,7 +244,7 @@ struct party_data *inter_party_fromsql(int party_id)
return NULL;
}
p->party.party_id = party_id;
- memcpy(&p->party.name, sql_row[1], NAME_LENGTH-1);
+ strncpy(&p->party.name, sql_row[1], NAME_LENGTH);
p->party.exp = atoi(sql_row[2])?1:0;
p->party.item = atoi(sql_row[3]);
leader_id = atoi(sql_row[4]);
diff --git a/src/char_sql/int_pet.c b/src/char_sql/int_pet.c
index 3f6406be5..6352412ce 100644
--- a/src/char_sql/int_pet.c
+++ b/src/char_sql/int_pet.c
@@ -1,9 +1,6 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
-// original code from athena
-// SQL conversion by Jioh L. Jung
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -81,7 +78,7 @@ int inter_pet_fromsql(int pet_id, struct s_pet *p){
p->pet_id = pet_id;
p->class_ = atoi(sql_row[1]);
- memcpy(p->name, sql_row[2],NAME_LENGTH-1);
+ strncpy(p->name, sql_row[2], NAME_LENGTH);
p->account_id = atoi(sql_row[3]);
p->char_id = atoi(sql_row[4]);
p->level = atoi(sql_row[5]);
@@ -192,10 +189,10 @@ int mapif_delete_pet_ack(int fd, int flag){
}
int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short pet_lv, short pet_egg_id,
- short pet_equip, short intimate, short hungry, char rename_flag, char incuvate, char *pet_name){
-
+ short pet_equip, short intimate, short hungry, char rename_flag, char incuvate, char *pet_name)
+{
memset(pet_pt, 0, sizeof(struct s_pet));
- memcpy(pet_pt->name, pet_name, NAME_LENGTH-1);
+ strncpy(pet_pt->name, pet_name, NAME_LENGTH);
if(incuvate == 1)
pet_pt->account_id = pet_pt->char_id = 0;
else {