ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/player.C
(Generate patch)

Comparing deliantra/server/server/player.C (file contents):
Revision 1.174 by root, Thu Nov 8 19:43:27 2007 UTC vs.
Revision 1.175 by elmex, Mon Nov 26 12:54:32 2007 UTC

1008 if (op->move_type & MOVE_FLYING) 1008 if (op->move_type & MOVE_FLYING)
1009 return 1; 1009 return 1;
1010 1010
1011 next = op->below; 1011 next = op->below;
1012 1012
1013 int cnt = MAX_ITEM_PER_DROP;
1014#define CHK_PICK_PICKUP do { pick_up (op, tmp); cnt--; } while (0)
1015
1013 /* loop while there are items on the floor that are not marked as 1016 /* loop while there are items on the floor that are not marked as
1014 * destroyed */ 1017 * destroyed */
1015 while (next && !next->destroyed ()) 1018 while (next && !next->destroyed ())
1016 { 1019 {
1017 tmp = next; 1020 tmp = next;
1018 next = tmp->below; 1021 next = tmp->below;
1019 1022
1023 if (cnt <= 0)
1024 {
1025 op->failmsg ("Couldn't pickup all items at once.");
1026 return 0;
1027 }
1028
1020 if (op->destroyed ()) 1029 if (op->destroyed ())
1021 return 0; 1030 return 0;
1022 1031
1023 if (!can_pick (op, tmp)) 1032 if (!can_pick (op, tmp))
1024 continue; 1033 continue;
1025 1034
1026 if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE) 1035 if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE)
1027 { 1036 {
1028 if (item_matched_string (op, tmp, op->contr->search_str)) 1037 if (item_matched_string (op, tmp, op->contr->search_str))
1029 pick_up (op, tmp); 1038 CHK_PICK_PICKUP;
1030 continue; 1039 continue;
1031 } 1040 }
1032 1041
1033 /* high not bit set? We're using the old autopickup model */ 1042 /* high not bit set? We're using the old autopickup model */
1034 if (!(op->contr->mode & PU_NEWMODE)) 1043 if (!(op->contr->mode & PU_NEWMODE))
1036 switch (op->contr->mode) 1045 switch (op->contr->mode)
1037 { 1046 {
1038 case 0: 1047 case 0:
1039 return 1; /* don't pick up */ 1048 return 1; /* don't pick up */
1040 case 1: 1049 case 1:
1041 pick_up (op, tmp); 1050 CHK_PICK_PICKUP;
1042 return 1; 1051 return 1;
1043 case 2: 1052 case 2:
1044 pick_up (op, tmp); 1053 CHK_PICK_PICKUP;
1045 return 0; 1054 return 0;
1046 case 3: 1055 case 3:
1047 return 0; /* stop before pickup */ 1056 return 0; /* stop before pickup */
1048 case 4: 1057 case 4:
1049 pick_up (op, tmp); 1058 CHK_PICK_PICKUP;
1050 break; 1059 break;
1051 case 5: 1060 case 5:
1052 pick_up (op, tmp); 1061 CHK_PICK_PICKUP;
1053 stop = 1; 1062 stop = 1;
1054 break; 1063 break;
1055 case 6: 1064 case 6:
1056 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) 1065 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL)
1057 pick_up (op, tmp); 1066 && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))
1067 CHK_PICK_PICKUP;
1058 break; 1068 break;
1059 1069
1060 case 7: 1070 case 7:
1061 if (tmp->type == MONEY || tmp->type == GEM) 1071 if (tmp->type == MONEY || tmp->type == GEM)
1062 pick_up (op, tmp); 1072 CHK_PICK_PICKUP;
1063 break; 1073 break;
1064 1074
1065 default: 1075 default:
1066 /* use value density */ 1076 /* use value density */
1067 if (!QUERY_FLAG (tmp, FLAG_UNPAID) 1077 if (!QUERY_FLAG (tmp, FLAG_UNPAID)
1068 && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode) 1078 && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode)
1069 pick_up (op, tmp); 1079 CHK_PICK_PICKUP;
1070 } 1080 }
1071 } 1081 }
1072 else 1082 else
1073 { /* old model */ 1083 { /* old model */
1074 /* NEW pickup handling */ 1084 /* NEW pickup handling */
1129 /* all food and drink if desired */ 1139 /* all food and drink if desired */
1130 /* question: don't pick up known-poisonous stuff? */ 1140 /* question: don't pick up known-poisonous stuff? */
1131 if (op->contr->mode & PU_FOOD) 1141 if (op->contr->mode & PU_FOOD)
1132 if (tmp->type == FOOD) 1142 if (tmp->type == FOOD)
1133 { 1143 {
1134 pick_up (op, tmp); 1144 CHK_PICK_PICKUP;
1135 continue; 1145 continue;
1136 } 1146 }
1137 1147
1138 if (op->contr->mode & PU_DRINK) 1148 if (op->contr->mode & PU_DRINK)
1139 if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) 1149 if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)))
1140 { 1150 {
1141 pick_up (op, tmp); 1151 CHK_PICK_PICKUP;
1142 continue; 1152 continue;
1143 } 1153 }
1144 1154
1145 if (op->contr->mode & PU_POTION) 1155 if (op->contr->mode & PU_POTION)
1146 if (tmp->type == POTION) 1156 if (tmp->type == POTION)
1147 { 1157 {
1148 pick_up (op, tmp); 1158 CHK_PICK_PICKUP;
1149 continue; 1159 continue;
1150 } 1160 }
1151 1161
1152 /* spellbooks, skillscrolls and normal books/scrolls */ 1162 /* spellbooks, skillscrolls and normal books/scrolls */
1153 if (op->contr->mode & PU_SPELLBOOK) 1163 if (op->contr->mode & PU_SPELLBOOK)
1154 if (tmp->type == SPELLBOOK) 1164 if (tmp->type == SPELLBOOK)
1155 { 1165 {
1156 pick_up (op, tmp); 1166 CHK_PICK_PICKUP;
1157 continue; 1167 continue;
1158 } 1168 }
1159 1169
1160 if (op->contr->mode & PU_SKILLSCROLL) 1170 if (op->contr->mode & PU_SKILLSCROLL)
1161 if (tmp->type == SKILLSCROLL) 1171 if (tmp->type == SKILLSCROLL)
1162 { 1172 {
1163 pick_up (op, tmp); 1173 CHK_PICK_PICKUP;
1164 continue; 1174 continue;
1165 } 1175 }
1166 1176
1167 if (op->contr->mode & PU_READABLES) 1177 if (op->contr->mode & PU_READABLES)
1168 if (tmp->type == BOOK || tmp->type == SCROLL || tmp->type == INSCRIBABLE) 1178 if (tmp->type == BOOK || tmp->type == SCROLL || tmp->type == INSCRIBABLE)
1169 { 1179 {
1170 pick_up (op, tmp); 1180 CHK_PICK_PICKUP;
1171 continue; 1181 continue;
1172 } 1182 }
1173 1183
1174 /* wands/staves/rods/horns */ 1184 /* wands/staves/rods/horns */
1175 if (op->contr->mode & PU_MAGIC_DEVICE) 1185 if (op->contr->mode & PU_MAGIC_DEVICE)
1176 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) 1186 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN)
1177 { 1187 {
1178 pick_up (op, tmp); 1188 CHK_PICK_PICKUP;
1179 continue; 1189 continue;
1180 } 1190 }
1181 1191
1182 /* pick up all magical items */ 1192 /* pick up all magical items */
1183 if (op->contr->mode & PU_MAGICAL) 1193 if (op->contr->mode & PU_MAGICAL)
1184 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) 1194 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))
1185 { 1195 {
1186 pick_up (op, tmp); 1196 CHK_PICK_PICKUP;
1187 continue; 1197 continue;
1188 } 1198 }
1189 1199
1190 if (op->contr->mode & PU_VALUABLES) 1200 if (op->contr->mode & PU_VALUABLES)
1191 { 1201 {
1192 if (tmp->type == MONEY || tmp->type == GEM) 1202 if (tmp->type == MONEY || tmp->type == GEM)
1193 { 1203 {
1194 pick_up (op, tmp); 1204 CHK_PICK_PICKUP;
1195 continue; 1205 continue;
1196 } 1206 }
1197 } 1207 }
1198 1208
1199 /* rings & amulets - talismans seems to be typed AMULET */ 1209 /* rings & amulets - talismans seems to be typed AMULET */
1200 if (op->contr->mode & PU_JEWELS) 1210 if (op->contr->mode & PU_JEWELS)
1201 if (tmp->type == RING || tmp->type == AMULET) 1211 if (tmp->type == RING || tmp->type == AMULET)
1202 { 1212 {
1203 pick_up (op, tmp); 1213 CHK_PICK_PICKUP;
1204 continue; 1214 continue;
1205 } 1215 }
1206 1216
1207 /* we don't forget dragon food */ 1217 /* we don't forget dragon food */
1208 if (op->contr->mode & PU_FLESH) 1218 if (op->contr->mode & PU_FLESH)
1209 if (tmp->type == FLESH) 1219 if (tmp->type == FLESH)
1210 { 1220 {
1211 pick_up (op, tmp); 1221 CHK_PICK_PICKUP;
1212 continue; 1222 continue;
1213 } 1223 }
1214 1224
1215 /* bows and arrows. Bows are good for selling! */ 1225 /* bows and arrows. Bows are good for selling! */
1216 if (op->contr->mode & PU_BOW) 1226 if (op->contr->mode & PU_BOW)
1217 if (tmp->type == BOW) 1227 if (tmp->type == BOW)
1218 { 1228 {
1219 pick_up (op, tmp); 1229 CHK_PICK_PICKUP;
1220 continue; 1230 continue;
1221 } 1231 }
1222 1232
1223 if (op->contr->mode & PU_ARROW) 1233 if (op->contr->mode & PU_ARROW)
1224 if (tmp->type == ARROW) 1234 if (tmp->type == ARROW)
1225 { 1235 {
1226 pick_up (op, tmp); 1236 CHK_PICK_PICKUP;
1227 continue; 1237 continue;
1228 } 1238 }
1229 1239
1230 /* all kinds of armor etc. */ 1240 /* all kinds of armor etc. */
1231 if (op->contr->mode & PU_ARMOUR) 1241 if (op->contr->mode & PU_ARMOUR)
1232 if (tmp->type == ARMOUR) 1242 if (tmp->type == ARMOUR)
1233 { 1243 {
1234 pick_up (op, tmp); 1244 CHK_PICK_PICKUP;
1235 continue; 1245 continue;
1236 } 1246 }
1237 1247
1238 if (op->contr->mode & PU_HELMET) 1248 if (op->contr->mode & PU_HELMET)
1239 if (tmp->type == HELMET) 1249 if (tmp->type == HELMET)
1240 { 1250 {
1241 pick_up (op, tmp); 1251 CHK_PICK_PICKUP;
1242 continue; 1252 continue;
1243 } 1253 }
1244 1254
1245 if (op->contr->mode & PU_SHIELD) 1255 if (op->contr->mode & PU_SHIELD)
1246 if (tmp->type == SHIELD) 1256 if (tmp->type == SHIELD)
1247 { 1257 {
1248 pick_up (op, tmp); 1258 CHK_PICK_PICKUP;
1249 continue; 1259 continue;
1250 } 1260 }
1251 1261
1252 if (op->contr->mode & PU_BOOTS) 1262 if (op->contr->mode & PU_BOOTS)
1253 if (tmp->type == BOOTS) 1263 if (tmp->type == BOOTS)
1254 { 1264 {
1255 pick_up (op, tmp); 1265 CHK_PICK_PICKUP;
1256 continue; 1266 continue;
1257 } 1267 }
1258 1268
1259 if (op->contr->mode & PU_GLOVES) 1269 if (op->contr->mode & PU_GLOVES)
1260 if (tmp->type == GLOVES) 1270 if (tmp->type == GLOVES)
1261 { 1271 {
1262 pick_up (op, tmp); 1272 CHK_PICK_PICKUP;
1263 continue; 1273 continue;
1264 } 1274 }
1265 1275
1266 if (op->contr->mode & PU_CLOAK) 1276 if (op->contr->mode & PU_CLOAK)
1267 if (tmp->type == CLOAK) 1277 if (tmp->type == CLOAK)
1268 { 1278 {
1269 pick_up (op, tmp); 1279 CHK_PICK_PICKUP;
1270 continue; 1280 continue;
1271 } 1281 }
1272 1282
1273 /* hoping to catch throwing daggers here */ 1283 /* hoping to catch throwing daggers here */
1274 if (op->contr->mode & PU_MISSILEWEAPON) 1284 if (op->contr->mode & PU_MISSILEWEAPON)
1275 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) 1285 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN))
1276 { 1286 {
1277 pick_up (op, tmp); 1287 CHK_PICK_PICKUP;
1278 continue; 1288 continue;
1279 } 1289 }
1280 1290
1281 /* careful: chairs and tables are weapons! */ 1291 /* careful: chairs and tables are weapons! */
1282 if (op->contr->mode & PU_ALLWEAPON) 1292 if (op->contr->mode & PU_ALLWEAPON)
1284 if (tmp->type == WEAPON && tmp->name != NULL) 1294 if (tmp->type == WEAPON && tmp->name != NULL)
1285 { 1295 {
1286 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->archname, "table") == NULL && 1296 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->archname, "table") == NULL &&
1287 strstr (tmp->name, "chair") && strstr (tmp->arch->archname, "chair") == NULL) 1297 strstr (tmp->name, "chair") && strstr (tmp->arch->archname, "chair") == NULL)
1288 { 1298 {
1289 pick_up (op, tmp); 1299 CHK_PICK_PICKUP;
1290 continue; 1300 continue;
1291 } 1301 }
1292 } 1302 }
1293 1303
1294 if (tmp->type == WEAPON && tmp->name == NULL) 1304 if (tmp->type == WEAPON && tmp->name == NULL)
1295 { 1305 {
1296 if (strstr (tmp->arch->archname, "table") == NULL && strstr (tmp->arch->archname, "chair") == NULL) 1306 if (strstr (tmp->arch->archname, "table") == NULL && strstr (tmp->arch->archname, "chair") == NULL)
1297 { 1307 {
1298 pick_up (op, tmp); 1308 CHK_PICK_PICKUP;
1299 continue; 1309 continue;
1300 } 1310 }
1301 } 1311 }
1302 } 1312 }
1303 1313
1304 /* misc stuff that's useful */ 1314 /* misc stuff that's useful */
1305 if (op->contr->mode & PU_KEY) 1315 if (op->contr->mode & PU_KEY)
1306 if (tmp->type == KEY || tmp->type == SPECIAL_KEY) 1316 if (tmp->type == KEY || tmp->type == SPECIAL_KEY)
1307 { 1317 {
1308 pick_up (op, tmp); 1318 CHK_PICK_PICKUP;
1309 continue; 1319 continue;
1310 } 1320 }
1311 1321
1312 /* any of the last 4 bits set means we use the ratio for value 1322 /* any of the last 4 bits set means we use the ratio for value
1313 * pickups */ 1323 * pickups */
1318 /* >=7 is the old standard setting. Now we take the last 4 bits 1328 /* >=7 is the old standard setting. Now we take the last 4 bits
1319 * and multiply them by 5, giving 0..15*5== 5..75 */ 1329 * and multiply them by 5, giving 0..15*5== 5..75 */
1320 wvratio = (op->contr->mode & PU_RATIO) * 5; 1330 wvratio = (op->contr->mode & PU_RATIO) * 5;
1321 if ((query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= (unsigned int) wvratio) 1331 if ((query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= (unsigned int) wvratio)
1322 { 1332 {
1323 pick_up (op, tmp); 1333 CHK_PICK_PICKUP;
1324#if 0 1334#if 0
1325 fprintf (stderr, "HIGH WEIGHT/VALUE ["); 1335 fprintf (stderr, "HIGH WEIGHT/VALUE [");
1326 if (tmp->name != NULL) 1336 if (tmp->name != NULL)
1327 { 1337 {
1328 fprintf (stderr, "%s", tmp->name); 1338 fprintf (stderr, "%s", tmp->name);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines