- Implemented a small change that was long overdue: Displaying the char-select screen now uses a single SQL query instead of up to 9.

- Fixed a bug in the update to prevent setting cell types on unwalkable cells.


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11757 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
skotlex 2007-11-18 21:32:24 +00:00
parent 94896dc707
commit cf2d63d285
3 changed files with 84 additions and 22 deletions

View File

@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2007/11/18 2007/11/18
* Implemented a small change that was long overdue: Displaying the
char-select screen now uses a single SQL query instead of up to 9.
[Skotlex]
* Replaced jA's way of allocating npc shop data with a simple dynamic * Replaced jA's way of allocating npc shop data with a simple dynamic
array that gets allocated during loading and freed on unload array that gets allocated during loading and freed on unload
- automatically fixes bugreport:404, which would otherwise require - automatically fixes bugreport:404, which would otherwise require

View File

@ -822,7 +822,83 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
return 0; return 0;
} }
int mmo_char_tobuf(uint8* buf, struct mmo_charstatus* p);
#ifndef TXT_SQL_CONVERT #ifndef TXT_SQL_CONVERT
//=====================================================================================================
// Loads the basic character rooster for the given account. Returns total buffer used.
int mmo_chars_fromsql(struct char_session_data* sd, uint8* buf)
{
SqlStmt* stmt;
struct mmo_charstatus p;
int j = 0, i;
stmt = SqlStmt_Malloc(sql_handle);
if( stmt == NULL )
{
SqlStmt_ShowDebug(stmt);
return 0;
}
memset(&p, 0, sizeof(p));
// read char data
if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT "
"`char_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`,`hair`,`hair_color`,"
"`clothes_color`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom`"
" FROM `%s` WHERE `account_id`='%d' AND `char_num` < '%d'", char_db, sd->account_id, MAX_CHARS)
|| SQL_ERROR == SqlStmt_Execute(stmt)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &p.char_id, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_UCHAR, &p.slot, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &p.name, sizeof(p.name), NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_SHORT, &p.class_, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_UINT, &p.base_level, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_UINT, &p.job_level, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 6, SQLDT_UINT, &p.base_exp, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &p.job_exp, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 8, SQLDT_INT, &p.zeny, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 9, SQLDT_SHORT, &p.str, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 10, SQLDT_SHORT, &p.agi, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 11, SQLDT_SHORT, &p.vit, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 12, SQLDT_SHORT, &p.int_, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 13, SQLDT_SHORT, &p.dex, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 14, SQLDT_SHORT, &p.luk, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 15, SQLDT_INT, &p.max_hp, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 16, SQLDT_INT, &p.hp, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 17, SQLDT_INT, &p.max_sp, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 18, SQLDT_INT, &p.sp, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 19, SQLDT_USHORT, &p.status_point, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 20, SQLDT_USHORT, &p.skill_point, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 21, SQLDT_UINT, &p.option, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 22, SQLDT_UCHAR, &p.karma, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 23, SQLDT_SHORT, &p.manner, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 24, SQLDT_SHORT, &p.hair, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 25, SQLDT_SHORT, &p.hair_color, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 26, SQLDT_SHORT, &p.clothes_color, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 27, SQLDT_SHORT, &p.weapon, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 28, SQLDT_SHORT, &p.shield, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 29, SQLDT_SHORT, &p.head_top, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 30, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 31, SQLDT_SHORT, &p.head_bottom, 0, NULL, NULL)
)
{
SqlStmt_ShowDebug(stmt);
SqlStmt_Free(stmt);
return 0;
}
for( i = 0; i < MAX_CHARS && SQL_SUCCESS == SqlStmt_NextRow(stmt); i++ )
{
sd->found_char[i] = p.char_id;
j += mmo_char_tobuf(WBUFP(buf, j), &p);
}
for( ; i < MAX_CHARS; i++ )
sd->found_char[i] = -1;
SqlStmt_Free(stmt);
return j;
}
//===================================================================================================== //=====================================================================================================
int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything) int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything)
{ {
@ -1411,36 +1487,18 @@ int mmo_char_tobuf(uint8* buf, struct mmo_charstatus* p)
int mmo_char_send006b(int fd, struct char_session_data* sd) int mmo_char_send006b(int fd, struct char_session_data* sd)
{ {
int i, j, found_num = 0; int j;
char* data;
set_char_online(-1, 99, sd->account_id); set_char_online(-1, 99, sd->account_id);
// load the char_ids of all chars on this account
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id` FROM `%s` WHERE `account_id` = '%d' AND `char_num` < '%d'", char_db, sd->account_id, MAX_CHARS) )
Sql_ShowDebug(sql_handle);
for( i = 0; i < MAX_CHARS && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i )
{
Sql_GetData(sql_handle, 0, &data, NULL); sd->found_char[i] = atoi(data); // char_id
}
found_num = i;
for( ; i < MAX_CHARS; ++i )
sd->found_char[i] = -1;
if (save_log) if (save_log)
ShowInfo("Loading Char Data ("CL_BOLD"%d"CL_RESET")\n",sd->account_id); ShowInfo("Loading Char Data ("CL_BOLD"%d"CL_RESET")\n",sd->account_id);
j = 24; // offset j = 24; // offset
WFIFOHEAD(fd,j + found_num*108); // or 106(!) WFIFOHEAD(fd,j + MAX_CHARS*108); // or 106(!)
WFIFOW(fd,0) = 0x6b; WFIFOW(fd,0) = 0x6b;
memset(WFIFOP(fd,4), 0, 20); // unknown bytes memset(WFIFOP(fd,4), 0, 20); // unknown bytes
for(i = 0; i < found_num; i++) j+=mmo_chars_fromsql(sd, WFIFOP(fd,j));
{
struct mmo_charstatus char_dat;
mmo_char_fromsql(sd->found_char[i], &char_dat, false);
j += mmo_char_tobuf(WFIFOP(fd,j), &char_dat);
}
WFIFOW(fd,2) = j; // packet len WFIFOW(fd,2) = j; // packet len
WFIFOSET(fd,j); WFIFOSET(fd,j);

View File

@ -2543,10 +2543,11 @@ static const char* npc_parse_mapcell(char* w1, char* w2, char* w3, char* w4, con
swap(y0, y1); swap(y0, y1);
for( x = x0; x <= x1; ++x ) for( x = x0; x <= x1; ++x )
for( y = y0; y <= y1; ++y ) for( y = y0; y <= y1; ++y ) {
if (map_getcell(m, x, y, CELL_CHKNOREACH)) if (map_getcell(m, x, y, CELL_CHKNOREACH))
continue; continue;
map_setcell(m, x, y, cell); map_setcell(m, x, y, cell);
}
return strchr(start,'\n');// continue return strchr(start,'\n');// continue
} }