summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt2
-rw-r--r--src/map/clif.c20
-rw-r--r--src/map/script.c35
3 files changed, 25 insertions, 32 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 1aa4e2b39..dda417310 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,6 +4,8 @@ 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.
2006/11/24
+ * Fixed uninitialized variable fd being used in WFIFOHEAD in a few clif
+ functions. [Skotlex]
* Fixed the fact that the TURBO code breaks when you attempt to handle more
than one connection at a time within the same function. However this broke
map-server compilation, therefore, don't use TURBO yet! [Skotlex]
diff --git a/src/map/clif.c b/src/map/clif.c
index 97251a343..3d7d935fb 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -1542,12 +1542,9 @@ int clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag)
}
void clif_send_homdata(struct map_session_data *sd, int type, int param) { //[orn]
- int fd;
+ int fd = sd->fd;
WFIFOHEAD(fd, packet_len_table[0x230]);
- nullpo_retv(sd);
nullpo_retv(sd->hd);
-
- fd=sd->fd;
WFIFOW(fd,0)=0x230;
WFIFOW(fd,2)=type;
WFIFOL(fd,4)=sd->hd->bl.id;
@@ -1559,16 +1556,14 @@ void clif_send_homdata(struct map_session_data *sd, int type, int param) { //[or
int clif_homskillinfoblock(struct map_session_data *sd) { //[orn]
struct homun_data *hd;
- int fd;
+ int fd = sd->fd;
int i,j,len=4,id;
WFIFOHEAD(fd, 4+37*MAX_HOMUNSKILL);
- nullpo_retr(0, sd);
hd = sd->hd;
if ( !hd )
return 0 ;
- fd=sd->fd;
WFIFOW(fd,0)=0x235;
for ( i = 0; i < MAX_HOMUNSKILL; i++){
if( (id = hd->homunculus.hskill[i].id) != 0 ){
@@ -2023,13 +2018,9 @@ int clif_selllist(struct map_session_data *sd) {
*------------------------------------------
*/
int clif_scriptmes(struct map_session_data *sd, int npcid, char *mes) {
- int fd;
+ int fd = sd->fd;
int slen = strlen(mes) + 9;
WFIFOHEAD(fd, slen);
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
WFIFOW(fd,0)=0xb4;
WFIFOW(fd,2)=slen;
WFIFOL(fd,4)=npcid;
@@ -2099,19 +2090,16 @@ void clif_sendfakenpc(struct map_session_data *sd, int npcid) {
*------------------------------------------
*/
int clif_scriptmenu(struct map_session_data *sd, int npcid, char *mes) {
- int fd;
+ int fd = sd->fd;
int slen = strlen(mes) + 8;
struct block_list *bl = NULL;
WFIFOHEAD(fd, slen);
- nullpo_retr(0, sd);
-
if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
clif_sendfakenpc(sd, npcid);
- fd=sd->fd;
WFIFOW(fd,0)=0xb7;
WFIFOW(fd,2)=slen;
WFIFOL(fd,4)=npcid;
diff --git a/src/map/script.c b/src/map/script.c
index 914931ebf..350fcabbf 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -3927,8 +3927,10 @@ struct script_function buildin_func[] = {
*/
int buildin_mes(struct script_state *st)
{
+ struct map_session_data *sd = script_rid2sd(st);
conv_str(st,& (st->stack->stack_data[st->start+2]));
- clif_scriptmes(script_rid2sd(st),st->oid,st->stack->stack_data[st->start+2].u.str);
+ if (sd)
+ clif_scriptmes(sd,st->oid,st->stack->stack_data[st->start+2].u.str);
return 0;
}
@@ -4139,7 +4141,7 @@ int buildin_menu(struct script_state *st)
sd->state.menu_or_input=1;
if( (st->end - st->start - 2) % 2 == 1 ) {
// 引数の数が奇数なのでエラー扱い
- ShowError("buildin_menu: illigal argument count(%d).\n", st->end - st->start - 2);
+ ShowError("buildin_menu: illegal argument count(%d).\n", st->end - st->start - 2);
sd->state.menu_or_input=0;
st->state=END;
return 1;
@@ -4161,9 +4163,9 @@ int buildin_menu(struct script_state *st)
max++;
}
sd->max_menu = max;
- clif_scriptmenu(script_rid2sd(st),st->oid,buf);
+ clif_scriptmenu(sd,st->oid,buf);
aFree(buf);
- } else if(sd->npc_menu==0xff){ // cansel
+ } else if(sd->npc_menu==0xff){ // cancel
sd->state.menu_or_input=0;
st->state=END;
} else { // goto動作
@@ -7407,9 +7409,12 @@ int buildin_getusers(struct script_state *st)
*/
int buildin_getusersname(struct script_state *st)
{
- struct map_session_data *pl_sd = NULL, **pl_allsd;
+ struct map_session_data *sd, *pl_sd = NULL, **pl_allsd;
int i=0,disp_num=1, users;
-
+
+ sd = script_rid2sd(st);
+ if (!sd) return 0;
+
pl_allsd = map_getallusers(&users);
for (i=0;i<users;i++)
@@ -7418,8 +7423,8 @@ int buildin_getusersname(struct script_state *st)
if( !(battle_config.hide_GM_session && pc_isGM(pl_sd)) )
{
if((disp_num++)%10==0)
- clif_scriptnext(script_rid2sd(st),st->oid);
- clif_scriptmes(script_rid2sd(st),st->oid,pl_sd->status.name);
+ clif_scriptnext(sd,st->oid);
+ clif_scriptmes(sd,st->oid,pl_sd->status.name);
}
}
return 0;
@@ -10326,7 +10331,7 @@ int buildin_select(struct script_state *st)
struct map_session_data *sd;
sd=script_rid2sd(st);
-
+ nullpo_retr(0, sd);
if(sd->state.menu_or_input==0){
st->state=RERUNLINE;
sd->state.menu_or_input=1;
@@ -10345,12 +10350,12 @@ int buildin_select(struct script_state *st)
max++;
}
sd->max_menu = max;
- clif_scriptmenu(script_rid2sd(st),st->oid,buf);
+ clif_scriptmenu(sd,st->oid,buf);
aFree(buf);
} else if(sd->npc_menu==0xff){
sd->state.menu_or_input=0;
st->state=END;
- } else {
+ } else {
//Skip empty menu entries which weren't displayed on the client (Skotlex)
for(i=st->start+2;i< (st->start+2+sd->npc_menu) && sd->npc_menu < (st->end-st->start-2);i++) {
conv_str(st,& (st->stack->stack_data[i])); // we should convert variables to strings before access it [jA1983] [EoE]
@@ -10371,6 +10376,7 @@ int buildin_prompt(struct script_state *st)
struct map_session_data *sd;
sd=script_rid2sd(st);
+ nullpo_retr(0, sd);
if(sd->state.menu_or_input==0){
st->state=RERUNLINE;
@@ -10390,12 +10396,9 @@ int buildin_prompt(struct script_state *st)
max++;
}
sd->max_menu = max;
- clif_scriptmenu(script_rid2sd(st),st->oid,buf);
+ clif_scriptmenu(sd,st->oid,buf);
aFree(buf);
- } /*else if(sd->npc_menu==0xff){
- sd->state.menu_or_input=0;
- st->state=END;
- }*/ else {
+ } else {
if(sd->npc_menu != 0xff){
//Skip empty menu entries which weren't displayed on the client (Skotlex)
for(i=st->start+2;i< (st->start+2+sd->npc_menu) && sd->npc_menu < (st->end-st->start-2);i++) {