diff options
author | greenboxal2 <greenboxal2@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-11-25 21:20:43 +0000 |
---|---|---|
committer | greenboxal2 <greenboxal2@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-11-25 21:20:43 +0000 |
commit | b11bf6e1604097711291265f927e79e8f2af5c54 (patch) | |
tree | 6eac67dfe94b2cef4e48f59c1bf448a321ce24cd /src/char/int_elemental.c | |
parent | d9c5c4784a0abc43fb9e01f365a0d8b3a15a0692 (diff) | |
download | hercules-b11bf6e1604097711291265f927e79e8f2af5c54.tar.gz hercules-b11bf6e1604097711291265f927e79e8f2af5c54.tar.bz2 hercules-b11bf6e1604097711291265f927e79e8f2af5c54.tar.xz hercules-b11bf6e1604097711291265f927e79e8f2af5c54.zip |
Applied AStyle code formating as discussed on tid:74602.
Removed /SAFESEH option from MSVC11 projects.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16968 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char/int_elemental.c')
-rw-r--r-- | src/char/int_elemental.c | 266 |
1 files changed, 149 insertions, 117 deletions
diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c index 7c76c4496..aa7ef5f65 100644 --- a/src/char/int_elemental.c +++ b/src/char/int_elemental.c @@ -15,147 +15,179 @@ #include <stdlib.h> #include <string.h> -bool mapif_elemental_save(struct s_elemental* ele) { - bool flag = true; - - if( ele->elemental_id == 0 ) { // Create new DB entry - if( SQL_ERROR == Sql_Query(sql_handle, - "INSERT INTO `elemental` (`char_id`,`class`,`mode`,`hp`,`sp`,`max_hp`,`max_sp`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`life_time`)" - "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%u')", - ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->str, ele->agi, ele->vit, ele->int_, ele->dex, ele->luk, ele->life_time) ) - { - Sql_ShowDebug(sql_handle); - flag = false; - } - else - ele->elemental_id = (int)Sql_LastInsertId(sql_handle); - } else if( SQL_ERROR == Sql_Query(sql_handle, - "UPDATE `elemental` SET `char_id` = '%d', `class` = '%d', `mode` = '%d', `hp` = '%d', `sp` = '%d'," - "`max_hp` = '%d', `max_sp` = '%d', `str` = '%d', `agi` = '%d', `vit` = '%d', `int` = '%d', `dex` = '%d'," - "`luk` = '%d', `life_time` = '%u' WHERE `ele_id` = '%d'", - ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->str, ele->agi, - ele->vit, ele->int_, ele->dex, ele->luk, ele->life_time, ele->elemental_id) ) - { // Update DB entry - Sql_ShowDebug(sql_handle); - flag = false; - } - return flag; +bool mapif_elemental_save(struct s_elemental *ele) +{ + bool flag = true; + + if (ele->elemental_id == 0) { // Create new DB entry + if (SQL_ERROR == Sql_Query(sql_handle, + "INSERT INTO `elemental` (`char_id`,`class`,`mode`,`hp`,`sp`,`max_hp`,`max_sp`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`life_time`)" + "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%u')", + ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->str, ele->agi, ele->vit, ele->int_, ele->dex, ele->luk, ele->life_time)) { + Sql_ShowDebug(sql_handle); + flag = false; + } else + ele->elemental_id = (int)Sql_LastInsertId(sql_handle); + } else if (SQL_ERROR == Sql_Query(sql_handle, + "UPDATE `elemental` SET `char_id` = '%d', `class` = '%d', `mode` = '%d', `hp` = '%d', `sp` = '%d'," + "`max_hp` = '%d', `max_sp` = '%d', `str` = '%d', `agi` = '%d', `vit` = '%d', `int` = '%d', `dex` = '%d'," + "`luk` = '%d', `life_time` = '%u' WHERE `ele_id` = '%d'", + ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->str, ele->agi, + ele->vit, ele->int_, ele->dex, ele->luk, ele->life_time, ele->elemental_id)) { + // Update DB entry + Sql_ShowDebug(sql_handle); + flag = false; + } + return flag; } -bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) { - char* data; - - memset(ele, 0, sizeof(struct s_elemental)); - ele->elemental_id = ele_id; - ele->char_id = char_id; - - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `class`, `mode`, `hp`, `sp`, `max_hp`, `max_sp`, `str`, `agi`, `vit`, `int`, `dex`," - "`luk`, `life_time` FROM `elemental` WHERE `ele_id` = '%d' AND `char_id` = '%d'", - ele_id, char_id) ) { - Sql_ShowDebug(sql_handle); - return false; - } - - if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) { - Sql_FreeResult(sql_handle); - return false; - } - - Sql_GetData(sql_handle, 0, &data, NULL); ele->class_ = atoi(data); - Sql_GetData(sql_handle, 1, &data, NULL); ele->mode = atoi(data); - Sql_GetData(sql_handle, 2, &data, NULL); ele->hp = atoi(data); - Sql_GetData(sql_handle, 3, &data, NULL); ele->sp = atoi(data); - Sql_GetData(sql_handle, 4, &data, NULL); ele->max_hp = atoi(data); - Sql_GetData(sql_handle, 5, &data, NULL); ele->max_sp = atoi(data); - Sql_GetData(sql_handle, 6, &data, NULL); ele->str = atoi(data); - Sql_GetData(sql_handle, 7, &data, NULL); ele->agi = atoi(data); - Sql_GetData(sql_handle, 8, &data, NULL); ele->vit = atoi(data); - Sql_GetData(sql_handle, 9, &data, NULL); ele->int_ = atoi(data); - Sql_GetData(sql_handle, 10, &data, NULL); ele->dex = atoi(data); - Sql_GetData(sql_handle, 11, &data, NULL); ele->luk = atoi(data); - Sql_GetData(sql_handle, 12, &data, NULL); ele->life_time = atoi(data); - Sql_FreeResult(sql_handle); - if( save_log ) - ShowInfo("Elemental loaded (%d - %d).\n", ele->elemental_id, ele->char_id); - - return true; +bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) +{ + char *data; + + memset(ele, 0, sizeof(struct s_elemental)); + ele->elemental_id = ele_id; + ele->char_id = char_id; + + if (SQL_ERROR == Sql_Query(sql_handle, "SELECT `class`, `mode`, `hp`, `sp`, `max_hp`, `max_sp`, `str`, `agi`, `vit`, `int`, `dex`," + "`luk`, `life_time` FROM `elemental` WHERE `ele_id` = '%d' AND `char_id` = '%d'", + ele_id, char_id)) { + Sql_ShowDebug(sql_handle); + return false; + } + + if (SQL_SUCCESS != Sql_NextRow(sql_handle)) { + Sql_FreeResult(sql_handle); + return false; + } + + Sql_GetData(sql_handle, 0, &data, NULL); + ele->class_ = atoi(data); + Sql_GetData(sql_handle, 1, &data, NULL); + ele->mode = atoi(data); + Sql_GetData(sql_handle, 2, &data, NULL); + ele->hp = atoi(data); + Sql_GetData(sql_handle, 3, &data, NULL); + ele->sp = atoi(data); + Sql_GetData(sql_handle, 4, &data, NULL); + ele->max_hp = atoi(data); + Sql_GetData(sql_handle, 5, &data, NULL); + ele->max_sp = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); + ele->str = atoi(data); + Sql_GetData(sql_handle, 7, &data, NULL); + ele->agi = atoi(data); + Sql_GetData(sql_handle, 8, &data, NULL); + ele->vit = atoi(data); + Sql_GetData(sql_handle, 9, &data, NULL); + ele->int_ = atoi(data); + Sql_GetData(sql_handle, 10, &data, NULL); + ele->dex = atoi(data); + Sql_GetData(sql_handle, 11, &data, NULL); + ele->luk = atoi(data); + Sql_GetData(sql_handle, 12, &data, NULL); + ele->life_time = atoi(data); + Sql_FreeResult(sql_handle); + if (save_log) + ShowInfo("Elemental loaded (%d - %d).\n", ele->elemental_id, ele->char_id); + + return true; } -bool mapif_elemental_delete(int ele_id) { - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `elemental` WHERE `ele_id` = '%d'", ele_id) ) { - Sql_ShowDebug(sql_handle); - return false; - } - - return true; +bool mapif_elemental_delete(int ele_id) +{ + if (SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `elemental` WHERE `ele_id` = '%d'", ele_id)) { + Sql_ShowDebug(sql_handle); + return false; + } + + return true; } -static void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag) { - int size = sizeof(struct s_elemental) + 5; - - WFIFOHEAD(fd,size); - WFIFOW(fd,0) = 0x387c; - WFIFOW(fd,2) = size; - WFIFOB(fd,4) = flag; - memcpy(WFIFOP(fd,5),ele,sizeof(struct s_elemental)); - WFIFOSET(fd,size); +static void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag) +{ + int size = sizeof(struct s_elemental) + 5; + + WFIFOHEAD(fd,size); + WFIFOW(fd,0) = 0x387c; + WFIFOW(fd,2) = size; + WFIFOB(fd,4) = flag; + memcpy(WFIFOP(fd,5),ele,sizeof(struct s_elemental)); + WFIFOSET(fd,size); } -static void mapif_parse_elemental_create(int fd, struct s_elemental* ele) { - bool result = mapif_elemental_save(ele); - mapif_elemental_send(fd, ele, result); +static void mapif_parse_elemental_create(int fd, struct s_elemental *ele) +{ + bool result = mapif_elemental_save(ele); + mapif_elemental_send(fd, ele, result); } -static void mapif_parse_elemental_load(int fd, int ele_id, int char_id) { - struct s_elemental ele; - bool result = mapif_elemental_load(ele_id, char_id, &ele); - mapif_elemental_send(fd, &ele, result); +static void mapif_parse_elemental_load(int fd, int ele_id, int char_id) +{ + struct s_elemental ele; + bool result = mapif_elemental_load(ele_id, char_id, &ele); + mapif_elemental_send(fd, &ele, result); } -static void mapif_elemental_deleted(int fd, unsigned char flag) { - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x387d; - WFIFOB(fd,2) = flag; - WFIFOSET(fd,3); +static void mapif_elemental_deleted(int fd, unsigned char flag) +{ + WFIFOHEAD(fd,3); + WFIFOW(fd,0) = 0x387d; + WFIFOB(fd,2) = flag; + WFIFOSET(fd,3); } -static void mapif_parse_elemental_delete(int fd, int ele_id) { - bool result = mapif_elemental_delete(ele_id); - mapif_elemental_deleted(fd, result); +static void mapif_parse_elemental_delete(int fd, int ele_id) +{ + bool result = mapif_elemental_delete(ele_id); + mapif_elemental_deleted(fd, result); } -static void mapif_elemental_saved(int fd, unsigned char flag) { - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x387e; - WFIFOB(fd,2) = flag; - WFIFOSET(fd,3); +static void mapif_elemental_saved(int fd, unsigned char flag) +{ + WFIFOHEAD(fd,3); + WFIFOW(fd,0) = 0x387e; + WFIFOB(fd,2) = flag; + WFIFOSET(fd,3); } -static void mapif_parse_elemental_save(int fd, struct s_elemental* ele) { - bool result = mapif_elemental_save(ele); - mapif_elemental_saved(fd, result); +static void mapif_parse_elemental_save(int fd, struct s_elemental *ele) +{ + bool result = mapif_elemental_save(ele); + mapif_elemental_saved(fd, result); } -void inter_elemental_sql_init(void) { - return; +void inter_elemental_sql_init(void) +{ + return; } -void inter_elemental_sql_final(void) { - return; +void inter_elemental_sql_final(void) +{ + return; } /*========================================== * Inter Packets *------------------------------------------*/ -int inter_elemental_parse_frommap(int fd) { - unsigned short cmd = RFIFOW(fd,0); - - switch( cmd ) { - case 0x307c: mapif_parse_elemental_create(fd, (struct s_elemental*)RFIFOP(fd,4)); break; - case 0x307d: mapif_parse_elemental_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break; - case 0x307e: mapif_parse_elemental_delete(fd, (int)RFIFOL(fd,2)); break; - case 0x307f: mapif_parse_elemental_save(fd, (struct s_elemental*)RFIFOP(fd,4)); break; - default: - return 0; - } - return 1; +int inter_elemental_parse_frommap(int fd) +{ + unsigned short cmd = RFIFOW(fd,0); + + switch (cmd) { + case 0x307c: + mapif_parse_elemental_create(fd, (struct s_elemental *)RFIFOP(fd,4)); + break; + case 0x307d: + mapif_parse_elemental_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); + break; + case 0x307e: + mapif_parse_elemental_delete(fd, (int)RFIFOL(fd,2)); + break; + case 0x307f: + mapif_parse_elemental_save(fd, (struct s_elemental *)RFIFOP(fd,4)); + break; + default: + return 0; + } + return 1; } |