- SC_BANANA_BOMB_SITDOWN & SC_SITDOWN_FORCE force player to wait unti duration ended before standing. (bugreport:9074) Confirmed by @raynra & reigneil

- Corrected check to finalizing vending/buyingstore autotrader datas, follow up 171e2f2. Thank Stingor
- Autotrade persistance updates: (suggestion from Napster)
--- Kicked player will be removed from vending or buyingstore table. This also avoid 'confusion' lookup when server restarted after the kicked player logged back and does autotrade.
--- feature.autotrade_direction, added -1 value to use last player's direction
--- feature.autotrade_head_direction, added for player's head direction
--- feature.autotrade_sit, added -1 value to use last player's condition (standing/sitting)
--- Please import/execute upgrade_20140723.sql

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>
This commit is contained in:
Cydh Ramdh 2014-07-23 13:26:04 +07:00
parent 20ac4c9d7a
commit 7fd6776194
9 changed files with 174 additions and 105 deletions

View File

@ -39,10 +39,21 @@ feature.autotrade: on
// In which direction should respawned autotraders look?
// Possible values are from 0-7
// Default: 4(South)
// -1 = Last player's direction
feature.autotrade_direction: 4
// Do you want your autotraders to sit? (Note 1)
feature.autotrade_sit: yes
// Change player's head direction?
// -1 = Last condition
// 0 = Forward
// 1 = Right
// 2 = Left
feature.autotrade_head_direction: 0
// Do you want your autotraders to sit?
// -1 = Last player's condition, sitting or standing
// 0 = Standing
// 1 = Sitting
feature.autotrade_sit: 1
// Delay in miliseconds to open vending/buyingsotre after player logged in.
feature.autotrade_open_delay: 5000

View File

@ -0,0 +1,7 @@
ALTER TABLE `vendings` ADD `body_direction` CHAR( 1 ) NOT NULL DEFAULT '4',
ADD `head_direction` CHAR( 1 ) NOT NULL DEFAULT '0',
ADD `sit` CHAR( 1 ) NOT NULL DEFAULT '1';
ALTER TABLE `buyingstores` ADD `body_direction` CHAR( 1 ) NOT NULL DEFAULT '4',
ADD `head_direction` CHAR( 1 ) NOT NULL DEFAULT '0',
ADD `sit` CHAR( 1 ) NOT NULL DEFAULT '1';

View File

@ -66,7 +66,7 @@ static void logclif_auth_ok(struct login_session_data* sd) {
logclif_sent_auth_result(fd,1); // server closed
return;
} else if( login_config.min_group_id_to_connect >= 0 && login_config.group_id_to_connect == -1 && sd->group_id < login_config.min_group_id_to_connect ) {
ShowStatus("Connection refused: the minium group id required for connection is %d (account: %s, group: %d).\n", login_config.min_group_id_to_connect, sd->userid, sd->group_id);
ShowStatus("Connection refused: the minimum group id required for connection is %d (account: %s, group: %d).\n", login_config.min_group_id_to_connect, sd->userid, sd->group_id);
logclif_sent_auth_result(fd,1); // server closed
return;
}

View File

@ -7755,8 +7755,9 @@ static const struct _battle_data {
{ "update_enemy_position", &battle_config.update_enemy_position, 0, 0, 1, },
{ "devotion_rdamage", &battle_config.devotion_rdamage, 0, 0, 100, },
{ "feature.autotrade", &battle_config.feature_autotrade, 1, 0, 1, },
{ "feature.autotrade_direction", &battle_config.feature_autotrade_direction, 4, 0, 7, },
{ "feature.autotrade_sit", &battle_config.feature_autotrade_sit, 1, 0, 1, },
{ "feature.autotrade_direction", &battle_config.feature_autotrade_direction, 4, -1, 7, },
{ "feature.autotrade_head_direction", &battle_config.feature_autotrade_head_direction,0, -1, 2, },
{ "feature.autotrade_sit", &battle_config.feature_autotrade_sit, 1, -1, 1, },
{ "feature.autotrade_open_delay", &battle_config.feature_autotrade_open_delay, 5000, 1000, INT_MAX, },
{ "disp_serverbank_msg", &battle_config.disp_serverbank_msg, 0, 0, 1, },
{ "warg_can_falcon", &battle_config.warg_can_falcon, 0, 0, 1, },

View File

@ -536,6 +536,7 @@ extern struct Battle_Config
// autotrade persistency
int feature_autotrade;
int feature_autotrade_direction;
int feature_autotrade_head_direction;
int feature_autotrade_sit;
int feature_autotrade_open_delay;

View File

@ -31,7 +31,7 @@ struct s_autotrade {
int buyer_id;
int m;
uint16 x, y;
unsigned char sex;
unsigned char sex, dir, head_dir, sit;
char title[MESSAGE_SIZE];
int limit;
uint16 count;
@ -41,7 +41,7 @@ struct s_autotrade {
//Autotrader
static struct s_autotrade **autotraders; ///Autotraders Storage
static uint16 autotrader_count; ///Autotrader count
static uint16 autotrader_count, autotrader_loaded_count; ///Autotrader count
static void do_final_buyingstore_autotrade(void);
/// constants (client-side restrictions)
@ -237,7 +237,9 @@ char buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha
Sql_EscapeString( mmysql_handle, message_sql, sd->message );
if( Sql_Query( mmysql_handle, "INSERT INTO `%s`(`id`,`account_id`,`char_id`,`sex`,`map`,`x`,`y`,`title`,`limit`,`autotrade`) VALUES( %d, %d, %d, '%c', '%s', %d, %d, '%s', %d, %d );", buyingstore_db, sd->buyer_id, sd->status.account_id, sd->status.char_id, sd->status.sex == 0 ? 'F' : 'M', map[sd->bl.m].name, sd->bl.x, sd->bl.y, message_sql, sd->buyingstore.zenylimit, sd->state.autotrade ) != SQL_SUCCESS ){
if( Sql_Query( mmysql_handle, "INSERT INTO `%s`(`id`,`account_id`,`char_id`,`sex`,`map`,`x`,`y`,`title`,`limit`,`autotrade`, `body_direction`, `head_direction`, `sit`) "
"VALUES( %d, %d, %d, '%c', '%s', %d, %d, '%s', %d, %d, '%d', '%d', '%d' );",
buyingstore_db, sd->buyer_id, sd->status.account_id, sd->status.char_id, sd->status.sex == 0 ? 'F' : 'M', map[sd->bl.m].name, sd->bl.x, sd->bl.y, message_sql, sd->buyingstore.zenylimit, sd->state.autotrade, sd->ud.dir, sd->head_dir, pc_issit(sd) ) != SQL_SUCCESS ){
Sql_ShowDebug(mmysql_handle);
}
@ -603,6 +605,10 @@ void buyingstore_reopen( struct map_session_data* sd ){
p += 8;
}
// Make sure abort all NPCs
npc_event_dequeue(sd);
pc_cleareventtimer(sd);
// Open the buyingstore again
if( (fail = buyingstore_setup( sd, (unsigned char)autotraders[i]->count ) == 0) &&
(fail = buyingstore_create( sd, autotraders[i]->limit, 1, autotraders[i]->title, data, autotraders[i]->count ) == 0) )
@ -611,16 +617,17 @@ void buyingstore_reopen( struct map_session_data* sd ){
sd->status.name, count, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
// Set him to autotrade
if (Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;",
buyingstore_db, sd->buyer_id ) != SQL_SUCCESS )
if (Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1, `body_direction` = '%d', `head_direction` = '%d', `sit` = '%d' "
"WHERE `id` = %d;",
buyingstore_db, autotraders[i]->dir, autotraders[i]->head_dir, autotraders[i]->sit, sd->buyer_id ) != SQL_SUCCESS )
{
Sql_ShowDebug( mmysql_handle );
}
// Make him look perfect
unit_setdir(&sd->bl,battle_config.feature_autotrade_direction);
if( battle_config.feature_autotrade_sit )
// Make buyer look perfect
pc_setdir(sd, autotraders[i]->dir, autotraders[i]->head_dir);
clif_changed_dir(&sd->bl, AREA_WOS);
if( autotraders[i]->sit )
pc_setsit(sd);
// Immediate save
@ -635,7 +642,7 @@ void buyingstore_reopen( struct map_session_data* sd ){
aFree(data);
//If the last autotrade is loaded, clear autotraders [Cydh]
if (i+1 >= autotrader_count)
if (++autotrader_loaded_count >= autotrader_count)
do_final_buyingstore_autotrade();
}
}
@ -646,21 +653,22 @@ void buyingstore_reopen( struct map_session_data* sd ){
void do_init_buyingstore_autotrade( void ) {
if(battle_config.feature_autotrade) {
uint16 i, items = 0;
autotrader_count = 0;
autotrader_count = autotrader_loaded_count = 0;
// Get autotrader from table. `map`, `x`, and `y`, aren't used here
// Just read player that has data at buyingstore_items [Cydh]
if (Sql_Query(mmysql_handle,
"SELECT `id`, `account_id`, `char_id`, `sex`, `title`, `limit` "
"SELECT `id`, `account_id`, `char_id`, `sex`, `title`, `limit`, `body_direction`, `head_direction`, `sit` "
"FROM `%s` "
"WHERE `autotrade` = 1 AND `limit` > 0 AND (SELECT COUNT(`buyingstore_id`) FROM `%s` WHERE `buyingstore_id` = `id`) > 0;",
"WHERE `autotrade` = 1 AND `limit` > 0 AND (SELECT COUNT(`buyingstore_id`) FROM `%s` WHERE `buyingstore_id` = `id`) > 0 "
"ORDER BY `id`;",
buyingstore_db, buyingstore_items_db ) != SQL_SUCCESS )
{
Sql_ShowDebug(mmysql_handle);
return;
}
if( (autotrader_count = (uint32)Sql_NumRows(mmysql_handle)) > 0 ){
if( (autotrader_count = (uint16)Sql_NumRows(mmysql_handle)) > 0 ){
// Init autotraders
CREATE(autotraders, struct s_autotrade *, autotrader_count);
@ -675,49 +683,59 @@ void do_init_buyingstore_autotrade( void ) {
while (SQL_SUCCESS == Sql_NextRow(mmysql_handle) && i < autotrader_count) {
size_t len;
char* data;
struct s_autotrade *at = NULL;
CREATE(autotraders[i], struct s_autotrade, 1);
at = autotraders[i];
Sql_GetData(mmysql_handle, 0, &data, NULL); autotraders[i]->buyer_id = atoi(data);
Sql_GetData(mmysql_handle, 1, &data, NULL); autotraders[i]->account_id = atoi(data);
Sql_GetData(mmysql_handle, 2, &data, NULL); autotraders[i]->char_id = atoi(data);
Sql_GetData(mmysql_handle, 3, &data, NULL); autotraders[i]->sex = (data[0] == 'F') ? 0 : 1;
Sql_GetData(mmysql_handle, 4, &data, &len); safestrncpy(autotraders[i]->title, data, min(len + 1, MESSAGE_SIZE));
Sql_GetData(mmysql_handle, 5, &data, NULL); autotraders[i]->limit = atoi(data);
autotraders[i]->count = 0;
Sql_GetData(mmysql_handle, 0, &data, NULL); at->buyer_id = atoi(data);
Sql_GetData(mmysql_handle, 1, &data, NULL); at->account_id = atoi(data);
Sql_GetData(mmysql_handle, 2, &data, NULL); at->char_id = atoi(data);
Sql_GetData(mmysql_handle, 3, &data, NULL); at->sex = (data[0] == 'F') ? 0 : 1;
Sql_GetData(mmysql_handle, 4, &data, &len); safestrncpy(at->title, data, min(len + 1, MESSAGE_SIZE));
Sql_GetData(mmysql_handle, 5, &data, NULL); at->limit = atoi(data);
Sql_GetData(mmysql_handle, 6, &data, NULL); at->dir = atoi(data);
Sql_GetData(mmysql_handle, 7, &data, NULL); at->head_dir = atoi(data);
Sql_GetData(mmysql_handle, 8, &data, NULL); at->sit = atoi(data);
at->count = 0;
if (battle_config.feature_autotrade_direction >= 0)
at->dir = battle_config.feature_autotrade_direction;
if (battle_config.feature_autotrade_head_direction >= 0)
at->head_dir = battle_config.feature_autotrade_head_direction;
if (battle_config.feature_autotrade_sit >= 0)
at->sit = battle_config.feature_autotrade_sit;
// initialize player
CREATE(autotraders[i]->sd, struct map_session_data, 1);
pc_setnewpc(autotraders[i]->sd, autotraders[i]->account_id, autotraders[i]->char_id, 0, gettick(), autotraders[i]->sex, 0);
autotraders[i]->sd->state.autotrade = 1;
autotraders[i]->sd->state.monster_ignore = (battle_config.autotrade_monsterignore);
chrif_authreq(autotraders[i]->sd, true);
CREATE(at->sd, struct map_session_data, 1);
pc_setnewpc(at->sd, at->account_id, at->char_id, 0, gettick(), at->sex, 0);
at->sd->state.autotrade = 1;
at->sd->state.monster_ignore = (battle_config.autotrade_monsterignore);
chrif_authreq(at->sd, true);
i++;
}
Sql_FreeResult(mmysql_handle);
//Init items on vending list each autotrader
//Init items on buying list each autotrader
for (i = 0; i < autotrader_count; i++){
struct s_autotrade *at = NULL;
uint16 j;
if (autotraders[i] == NULL)
if ((at = autotraders[i]) == NULL)
continue;
at = autotraders[i];
if (SQL_ERROR == Sql_Query(mmysql_handle,
"SELECT `item_id`, `amount`, `price` "
"FROM `%s` "
"WHERE `buyingstore_id` = %d "
"ORDER BY `index` ASC;", buyingstore_items_db, at->buyer_id ) )
"ORDER BY `index` ASC;",
buyingstore_items_db, at->buyer_id ) )
{
Sql_ShowDebug(mmysql_handle);
continue;
}
if (!(at->count = (uint32)Sql_NumRows(mmysql_handle))) {
if (!(at->count = (uint16)Sql_NumRows(mmysql_handle))) {
map_quit(at->sd);
continue;
}

View File

@ -1130,6 +1130,9 @@ int chrif_disconnectplayer(int fd) {
if( sd->state.vending ){
vending_closevending(sd);
}
else if( sd->state.buyingstore ){
buyingstore_close(sd);
}
map_quit(sd); //Remove it.
}

View File

@ -8368,8 +8368,16 @@ void clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd)
if( fd > 0 )
clif_authfail_fd(fd, 15);
else
else {
// Close vending/buyingstore
if (sd) {
if (tsd->state.vending)
vending_closevending(tsd);
else if (tsd->state.buyingstore)
buyingstore_close(tsd);
}
map_quit(tsd);
}
if( sd )
clif_GM_kickack(sd,tsd->status.account_id);
@ -10360,6 +10368,12 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type,
return;
}
// Cannot stand yet
// TODO: Move to SCS_NOSTAND [Cydh]
if (&sd->sc && (sd->sc.data[SC_SITDOWN_FORCE] || sd->sc.data[SC_BANANA_BOMB_SITDOWN])) {
return;
}
sd->idletime = last_tick;
pc_setstand(sd);
skill_sit(sd, 0);
@ -12975,43 +12989,43 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd)
}
switch (target->type) {
case BL_PC:
{
char command[NAME_LENGTH+6];
safesnprintf(command,sizeof(command),"%ckick %s", atcommand_symbol, status_get_name(target));
is_atcommand(fd, sd, command, 1);
}
break;
case BL_PC:
{
char command[NAME_LENGTH+6];
safesnprintf(command,sizeof(command),"%ckick %s", atcommand_symbol, status_get_name(target));
is_atcommand(fd, sd, command, 1);
}
break;
/**
* This one does not invoke any atcommand, so we need to check for permissions.
*/
case BL_MOB:
{
char command[100];
if( !pc_can_use_command(sd, "killmonster", COMMAND_ATCOMMAND)) {
/**
* This one does not invoke any atcommand, so we need to check for permissions.
*/
case BL_MOB:
{
char command[100];
if( !pc_can_use_command(sd, "killmonster", COMMAND_ATCOMMAND)) {
clif_GM_kickack(sd, 0);
return;
}
safesnprintf(command,sizeof(command),"/kick %s (%d)", status_get_name(target), status_get_class(target));
log_atcommand(sd, command);
status_percent_damage(&sd->bl, target, 100, 0, true); // can invalidate 'target'
}
break;
case BL_NPC:
{
struct npc_data* nd = (struct npc_data *)target;
if( pc_can_use_command(sd, "unloadnpc", COMMAND_ATCOMMAND)) {
npc_unload_duplicates(nd);
npc_unload(nd,true);
npc_read_event_script();
}
}
break;
default:
clif_GM_kickack(sd, 0);
return;
}
safesnprintf(command,sizeof(command),"/kick %s (%d)", status_get_name(target), status_get_class(target));
log_atcommand(sd, command);
status_percent_damage(&sd->bl, target, 100, 0, true); // can invalidate 'target'
}
break;
case BL_NPC:
{
struct npc_data* nd = (struct npc_data *)target;
if( pc_can_use_command(sd, "unloadnpc", COMMAND_ATCOMMAND)) {
npc_unload_duplicates(nd);
npc_unload(nd,true);
npc_read_event_script();
}
}
break;
default:
clif_GM_kickack(sd, 0);
}
}

View File

@ -39,7 +39,7 @@ struct s_autotrade {
int m;
uint16 x,
y;
unsigned char sex;
unsigned char sex, dir, head_dir, sit;
char title[MESSAGE_SIZE];
uint16 count;
struct s_autotrade_entry **entries;
@ -51,7 +51,7 @@ static DBMap *vending_db; ///Db holder the vender : charid -> map_session_data
//Autotrader
static struct s_autotrade **autotraders; ///Autotraders Storage
static uint16 autotrader_count; ///Autotrader count
static uint16 autotrader_count, autotrader_loaded_count; ///Autotrader count
static void do_final_vending_autotrade(void);
/**
@ -378,7 +378,9 @@ char vending_openvending(struct map_session_data* sd, const char* message, const
Sql_EscapeString( mmysql_handle, message_sql, sd->message );
if( Sql_Query( mmysql_handle, "INSERT INTO `%s`(`id`,`account_id`,`char_id`,`sex`,`map`,`x`,`y`,`title`,`autotrade`) VALUES( %d, %d, %d, '%c', '%s', %d, %d, '%s', %d );", vendings_db, sd->vender_id, sd->status.account_id, sd->status.char_id, sd->status.sex == 0 ? 'F' : 'M', map[sd->bl.m].name, sd->bl.x, sd->bl.y, message_sql, sd->state.autotrade ) != SQL_SUCCESS ){
if( Sql_Query( mmysql_handle, "INSERT INTO `%s`(`id`,`account_id`,`char_id`,`sex`,`map`,`x`,`y`,`title`,`autotrade`, `body_direction`, `head_direction`, `sit`) "
"VALUES( %d, %d, %d, '%c', '%s', %d, %d, '%s', %d, '%d', '%d', '%d' );",
vendings_db, sd->vender_id, sd->status.account_id, sd->status.char_id, sd->status.sex == 0 ? 'F' : 'M', map[sd->bl.m].name, sd->bl.x, sd->bl.y, message_sql, sd->state.autotrade, sd->ud.dir, sd->head_dir, pc_issit(sd) ) != SQL_SUCCESS ){
Sql_ShowDebug(mmysql_handle);
}
@ -526,16 +528,17 @@ void vending_reopen( struct map_session_data* sd ){
// Open the vending again
if( (fail = vending_openvending(sd, autotraders[i]->title, data, count)) == 0 ){
// Set him to autotrade
if (Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;",
vendings_db, sd->vender_id ) != SQL_SUCCESS )
if (Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1, `body_direction` = '%d', `head_direction` = '%d', `sit` = '%d' "
"WHERE `id` = %d;",
vendings_db, autotraders[i]->dir, autotraders[i]->head_dir, autotraders[i]->sit, sd->vender_id ) != SQL_SUCCESS )
{
Sql_ShowDebug( mmysql_handle );
}
// Make him look perfect
unit_setdir(&sd->bl,battle_config.feature_autotrade_direction);
if( battle_config.feature_autotrade_sit )
// Make vendor look perfect
pc_setdir(sd, autotraders[i]->dir, autotraders[i]->head_dir);
clif_changed_dir(&sd->bl, AREA_WOS);
if( autotraders[i]->sit )
pc_setsit(sd);
// Immediate save
@ -553,7 +556,7 @@ void vending_reopen( struct map_session_data* sd ){
aFree(data);
//If the last autotrade is loaded, clear autotraders [Cydh]
if (i+1 >= autotrader_count)
if (++autotrader_loaded_count >= autotrader_count)
do_final_vending_autotrade();
}
}
@ -564,21 +567,22 @@ void vending_reopen( struct map_session_data* sd ){
void do_init_vending_autotrade( void ) {
if (battle_config.feature_autotrade) {
uint16 i, items = 0;
autotrader_count = 0;
autotrader_count = autotrader_loaded_count = 0;
// Get autotrader from table. `map`, `x`, and `y`, aren't used here
// Just read player that has data at vending_items [Cydh]
if (Sql_Query(mmysql_handle,
"SELECT `id`, `account_id`, `char_id`, `sex`, `title` "
"SELECT `id`, `account_id`, `char_id`, `sex`, `title`, `body_direction`, `head_direction`, `sit` "
"FROM `%s` "
"WHERE `autotrade` = 1 AND (SELECT COUNT(`vending_id`) FROM `%s` WHERE `vending_id` = `id`) > 0;",
"WHERE `autotrade` = 1 AND (SELECT COUNT(`vending_id`) FROM `%s` WHERE `vending_id` = `id`) > 0 "
"ORDER BY `id`;",
vendings_db, vending_items_db ) != SQL_SUCCESS )
{
Sql_ShowDebug(mmysql_handle);
return;
}
if( (autotrader_count = (uint32)Sql_NumRows(mmysql_handle)) > 0 ){
if( (autotrader_count = (uint16)Sql_NumRows(mmysql_handle)) > 0 ){
// Init autotraders
CREATE(autotraders, struct s_autotrade *, autotrader_count);
@ -593,24 +597,34 @@ void do_init_vending_autotrade( void ) {
while (SQL_SUCCESS == Sql_NextRow(mmysql_handle) && i < autotrader_count) {
size_t len;
char* data;
struct s_autotrade *at = NULL;
CREATE(autotraders[i], struct s_autotrade, 1);
at = autotraders[i];
Sql_GetData(mmysql_handle, 0, &data, NULL); autotraders[i]->vendor_id = atoi(data);
Sql_GetData(mmysql_handle, 1, &data, NULL); autotraders[i]->account_id = atoi(data);
Sql_GetData(mmysql_handle, 2, &data, NULL); autotraders[i]->char_id = atoi(data);
Sql_GetData(mmysql_handle, 3, &data, NULL); autotraders[i]->sex = (data[0] == 'F') ? 0 : 1;
Sql_GetData(mmysql_handle, 4, &data, &len); safestrncpy(autotraders[i]->title, data, min(len + 1, MESSAGE_SIZE));
autotraders[i]->count = 0;
Sql_GetData(mmysql_handle, 0, &data, NULL); at->vendor_id = atoi(data);
Sql_GetData(mmysql_handle, 1, &data, NULL); at->account_id = atoi(data);
Sql_GetData(mmysql_handle, 2, &data, NULL); at->char_id = atoi(data);
Sql_GetData(mmysql_handle, 3, &data, NULL); at->sex = (data[0] == 'F') ? 0 : 1;
Sql_GetData(mmysql_handle, 4, &data, &len); safestrncpy(at->title, data, min(len + 1, MESSAGE_SIZE));
Sql_GetData(mmysql_handle, 5, &data, NULL); at->dir = atoi(data);
Sql_GetData(mmysql_handle, 6, &data, NULL); at->head_dir = atoi(data);
Sql_GetData(mmysql_handle, 7, &data, NULL); at->sit = atoi(data);
at->count = 0;
if (battle_config.feature_autotrade_direction >= 0)
at->dir = battle_config.feature_autotrade_direction;
if (battle_config.feature_autotrade_head_direction >= 0)
at->head_dir = battle_config.feature_autotrade_head_direction;
if (battle_config.feature_autotrade_sit >= 0)
at->sit = battle_config.feature_autotrade_sit;
// initialize player
CREATE(autotraders[i]->sd, struct map_session_data, 1);
pc_setnewpc(autotraders[i]->sd, autotraders[i]->account_id, autotraders[i]->char_id, 0, gettick(), autotraders[i]->sex, 0);
autotraders[i]->sd->state.autotrade = 1;
autotraders[i]->sd->state.monster_ignore = (battle_config.autotrade_monsterignore);
chrif_authreq(autotraders[i]->sd, true);
CREATE(at->sd, struct map_session_data, 1);
pc_setnewpc(at->sd, at->account_id, at->char_id, 0, gettick(), at->sex, 0);
at->sd->state.autotrade = 1;
at->sd->state.monster_ignore = (battle_config.autotrade_monsterignore);
chrif_authreq(at->sd, true);
i++;
}
Sql_FreeResult(mmysql_handle);
@ -620,21 +634,21 @@ void do_init_vending_autotrade( void ) {
struct s_autotrade *at = NULL;
uint16 j;
if (autotraders[i] == NULL)
if ((at = autotraders[i]) == NULL)
continue;
at = autotraders[i];
if (SQL_ERROR == Sql_Query(mmysql_handle,
"SELECT `cartinventory_id`, `amount`, `price` "
"FROM `%s` "
"WHERE `vending_id` = %d "
"ORDER BY `index` ASC;", vending_items_db, at->vendor_id ) )
"ORDER BY `index` ASC;",
vending_items_db, at->vendor_id ) )
{
Sql_ShowDebug(mmysql_handle);
continue;
}
if (!(at->count = (uint32)Sql_NumRows(mmysql_handle))) {
if (!(at->count = (uint16)Sql_NumRows(mmysql_handle))) {
map_quit(at->sd);
continue;
}