summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-03-10 15:53:39 -0600
committerJared Adams <jaxad0127@gmail.com>2009-03-10 15:53:39 -0600
commitbdc081d262eeb2adb3f3352026be431b846e48b1 (patch)
treed02c78e6ddbf014c8f6cc22887f79092834eec90
parent2d8ff1ae3793baa259b907b4a4b86230a725153b (diff)
downloadtmwa-bdc081d262eeb2adb3f3352026be431b846e48b1.tar.gz
tmwa-bdc081d262eeb2adb3f3352026be431b846e48b1.tar.bz2
tmwa-bdc081d262eeb2adb3f3352026be431b846e48b1.tar.xz
tmwa-bdc081d262eeb2adb3f3352026be431b846e48b1.zip
Apply sanity checks from Wombat
-rw-r--r--src/map/clif.c6
-rw-r--r--src/map/pc.c39
-rw-r--r--src/map/storage.c4
3 files changed, 37 insertions, 12 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 03bf1ab..dbee8b8 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -3065,10 +3065,10 @@ int clif_storageitemadded(struct map_session_data *sd,struct storage *stor,int i
WFIFOW(fd,0) =0xf4; // Storage item added
WFIFOW(fd,2) =index+1; // index
WFIFOL(fd,4) =amount; // amount
- if((view = itemdb_viewid(stor->storage[index].nameid)) > 0)
+/* if((view = itemdb_viewid(stor->storage[index].nameid)) > 0)
WFIFOW(fd,8) =view;
- else
- WFIFOW(fd,8) =stor->storage[index].nameid; // id
+ else*/
+ WFIFOW(fd,8) =stor->storage[index].nameid;
WFIFOB(fd,10)=stor->storage[index].identify; //identify flag
if(stor->storage[index].broken==1)
WFIFOB(fd,11)=1; // is weapon broken [Valaris]
diff --git a/src/map/pc.c b/src/map/pc.c
index afc4a20..8b3d9ef 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -422,15 +422,17 @@ int pc_equippoint(struct map_session_data *sd,int n)
nullpo_retr(0, sd);
+ if (!sd->inventory_data[n])
+ return 0;
+
s_class = pc_calc_base_job(sd->status.class);
- if(sd->inventory_data[n]) {
- ep = sd->inventory_data[n]->equip;
- if(sd->inventory_data[n]->look == 1 || sd->inventory_data[n]->look == 2 || sd->inventory_data[n]->look == 6) {
- if(ep == 2 && (pc_checkskill(sd,AS_LEFT) > 0 || s_class.job == 12))
- return 34;
- }
+ ep = sd->inventory_data[n]->equip;
+ if((sd->inventory_data[n]->look == 1 || sd->inventory_data[n]->look == 2 || sd->inventory_data[n]->look == 6) &&
+ (ep == 2 && (pc_checkskill(sd,AS_LEFT) > 0 || s_class.job == 12))) {
+ return 34;
}
+
return ep;
}
@@ -2953,6 +2955,7 @@ int pc_delitem(struct map_session_data *sd,int n,int amount,int type)
*/
int pc_dropitem(struct map_session_data *sd,int n,int amount)
{
+ int i;
nullpo_retr(1, sd);
if(n < 0 || n >= MAX_INVENTORY)
@@ -2960,6 +2963,14 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount)
if(amount <= 0)
return 0;
+
+ for (i = 0; i < 11; i++) {
+ if (equip_pos[i] > 0 && sd->equip_index[i] == n) { //Slot taken, remove item from there.
+ pc_unequipitem(sd, sd->equip_index[i], 1);
+ sd->equip_index[i] = -1;
+ }
+ }
+
if (sd->status.inventory[n].nameid <= 0 ||
sd->status.inventory[n].amount < amount ||
@@ -4842,8 +4853,10 @@ int pc_resetlvl(struct map_session_data* sd,int type)
for(i=0;i<11;i++) { // unequip items that can't be equipped by base 1 [Valaris]
if(sd->equip_index[i] >= 0)
- if(!pc_isequip(sd,sd->equip_index[i]))
+ if(!pc_isequip(sd,sd->equip_index[i])) {
pc_unequipitem(sd,sd->equip_index[i],1);
+ sd->equip_index[i] = -1;
+ }
}
clif_skillinfoblock(sd);
@@ -6278,6 +6291,12 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos)
nullpo_retr(0, sd);
+
+ if (n < 0 || n >= MAX_INVENTORY) {
+ clif_equipitemack(sd, 0, 0, 0);
+ return 0;
+ }
+
nameid = sd->status.inventory[n].nameid;
id = sd->inventory_data[n];
pos = pc_equippoint(sd,n);
@@ -6322,8 +6341,10 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos)
arrow=pc_search_inventory(sd,pc_checkequip(sd,9)); // Added by RoVeRT
for(i=0;i<11;i++) {
- if(sd->equip_index[i] >= 0 && sd->status.inventory[sd->equip_index[i]].equip&pos) {
- pc_unequipitem(sd,sd->equip_index[i],1);
+ if (pos & equip_pos[i]) {
+ if (sd->equip_index[i] >= 0) //Slot taken, remove item from there.
+ pc_unequipitem(sd, sd->equip_index[i], 1);
+ sd->equip_index[i] = n;
}
}
// 弓矢装備
diff --git a/src/map/storage.c b/src/map/storage.c
index ca7fa8b..3edd7b8 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -140,6 +140,7 @@ int storage_additem(struct map_session_data *sd,struct storage *stor,struct item
i=MAX_STORAGE;
if(!itemdb_isequip2(data)){
+ printf("A");
// 装備品ではないので、既所有品なら個数のみ変化させる
for(i=0;i<MAX_STORAGE;i++){
if(stor->storage[i].nameid == item_data->nameid &&
@@ -154,6 +155,7 @@ int storage_additem(struct map_session_data *sd,struct storage *stor,struct item
}
}
if(i>=MAX_STORAGE){
+ printf("B");
// 装備品か未所有品だったので空き欄へ追加
for(i=0;i<MAX_STORAGE;i++){
if(stor->storage[i].nameid==0){
@@ -228,6 +230,8 @@ int storage_storageget(struct map_session_data *sd,int index,int amount)
nullpo_retr(0, sd);
nullpo_retr(0, stor=account2storage(sd->status.account_id));
+ printf("A!\n");
+
if(stor->storage_status == 1) { // storage open
if(index>=0 && index<MAX_STORAGE) { // valid index
if( (amount <= stor->storage[index].amount) && (amount > 0) ) { //valid amount