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.43 by root, Sat Dec 16 03:08:26 2006 UTC vs.
Revision 1.50 by elmex, Wed Dec 20 10:31:00 2006 UTC

82 int comp; 82 int comp;
83 int size; 83 int size;
84 84
85 sprintf (buf, "%s/%s", settings.confdir, settings.motd); 85 sprintf (buf, "%s/%s", settings.confdir, settings.motd);
86 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) 86 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL)
87 {
88 return; 87 return;
89 } 88
90 motd[0] = '\0'; 89 motd[0] = '\0';
91 size = 0; 90 size = 0;
91
92 while (fgets (buf, MAX_BUF, fp) != NULL) 92 while (fgets (buf, MAX_BUF, fp) != NULL)
93 { 93 {
94 if (*buf == '#') 94 if (*buf == '#')
95 continue; 95 continue;
96
96 strncat (motd + size, buf, HUGE_BUF - size); 97 strncat (motd + size, buf, HUGE_BUF - size);
97 size += strlen (buf); 98 size += strlen (buf);
98 } 99 }
100
99 draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_MOTD, MSG_SUBTYPE_NONE, motd, NULL); 101 draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_MOTD, MSG_SUBTYPE_NONE, motd, NULL);
100 close_and_delete (fp, comp); 102 close_and_delete (fp, comp);
101} 103}
102 104
103void 105void
109 int comp; 111 int comp;
110 int size; 112 int size;
111 113
112 sprintf (buf, "%s/%s", settings.confdir, settings.rules); 114 sprintf (buf, "%s/%s", settings.confdir, settings.rules);
113 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) 115 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL)
114 {
115 return; 116 return;
116 } 117
117 rules[0] = '\0'; 118 rules[0] = '\0';
118 size = 0; 119 size = 0;
120
119 while (fgets (buf, MAX_BUF, fp) != NULL) 121 while (fgets (buf, MAX_BUF, fp) != NULL)
120 { 122 {
121 if (*buf == '#') 123 if (*buf == '#')
122 continue; 124 continue;
125
123 if (size + strlen (buf) >= HUGE_BUF) 126 if (size + strlen (buf) >= HUGE_BUF)
124 { 127 {
125 LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF); 128 LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF);
126 break; 129 break;
127 } 130 }
131
128 strncat (rules + size, buf, HUGE_BUF - size); 132 strncat (rules + size, buf, HUGE_BUF - size);
129 size += strlen (buf); 133 size += strlen (buf);
130 } 134 }
135
131 draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, rules, NULL); 136 draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, rules, NULL);
132 close_and_delete (fp, comp); 137 close_and_delete (fp, comp);
133} 138}
134 139
135void 140void
143 int size; 148 int size;
144 149
145 sprintf (buf, "%s/%s", settings.confdir, settings.news); 150 sprintf (buf, "%s/%s", settings.confdir, settings.news);
146 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) 151 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL)
147 return; 152 return;
153
148 news[0] = '\0'; 154 news[0] = '\0';
149 subject[0] = '\0'; 155 subject[0] = '\0';
150 size = 0; 156 size = 0;
157
151 while (fgets (buf, MAX_BUF, fp) != NULL) 158 while (fgets (buf, MAX_BUF, fp) != NULL)
152 { 159 {
153 if (*buf == '#') 160 if (*buf == '#')
154 continue; 161 continue;
162
155 if (*buf == '%') 163 if (*buf == '%')
156 { /* send one news */ 164 { /* send one news */
157 if (size > 0) 165 if (size > 0)
158 draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", "%s\n%s", subject, news); /*send previously read news */ 166 draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", "%s\n%s", subject, news); /*send previously read news */
159 strcpy (subject, buf + 1); 167 strcpy (subject, buf + 1);
186 return 0; 194 return 0;
187 195
188 for (; *cp != '\0'; cp++) 196 for (; *cp != '\0'; cp++)
189 if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z')) && *cp != '-' && *cp != '_') 197 if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z')) && *cp != '-' && *cp != '_')
190 return 0; 198 return 0;
199
191 return 1; 200 return 1;
192} 201}
193 202
194/* This no longer sets the player map. Also, it now updates 203/* This no longer sets the player map. Also, it now updates
195 * all the pointers so the caller doesn't need to do that. 204 * all the pointers so the caller doesn't need to do that.
254 p->usekeys = containers; 263 p->usekeys = containers;
255 p->last_weapon_sp = -1; 264 p->last_weapon_sp = -1;
256 p->peaceful = 1; /* default peaceful */ 265 p->peaceful = 1; /* default peaceful */
257 p->do_los = 1; 266 p->do_los = 1;
258 p->explore = 0; 267 p->explore = 0;
259 p->no_shout = 0; /* default can shout */
260 268
261 assign (p->title, op->arch->clone.name); 269 assign (p->title, op->arch->clone.name);
262 op->race = op->arch->clone.race; 270 op->race = op->arch->clone.race;
263 271
264 CLEAR_FLAG (op, FLAG_READY_SKILL); 272 CLEAR_FLAG (op, FLAG_READY_SKILL);
291set_first_map (object *op) 299set_first_map (object *op)
292{ 300{
293 strcpy (op->contr->maplevel, first_map_path); 301 strcpy (op->contr->maplevel, first_map_path);
294 op->x = -1; 302 op->x = -1;
295 op->y = -1; 303 op->y = -1;
296 enter_exit (op, NULL); 304 enter_exit (op, 0);
297} 305}
298 306
299/* Tries to add player on the connection passwd in ns. 307/* Tries to add player on the connection passwd in ns.
300 * All we can really get in this is some settings like host and display 308 * All we can really get in this is some settings like host and display
301 * mode. 309 * mode.
340 { 348 {
341 if (at == NULL || at->next == NULL) 349 if (at == NULL || at->next == NULL)
342 at = first_archetype; 350 at = first_archetype;
343 else 351 else
344 at = at->next; 352 at = at->next;
353
345 if (at->clone.type == PLAYER) 354 if (at->clone.type == PLAYER)
346 return at; 355 return at;
356
347 if (at == start) 357 if (at == start)
348 { 358 {
349 LOG (llevError, "No Player archetypes\n"); 359 LOG (llevError, "No Player archetypes\n");
350 exit (-1); 360 exit (-1);
351 } 361 }
352 } 362 }
353} 363}
354
355 364
356object * 365object *
357get_nearest_player (object *mon) 366get_nearest_player (object *mon)
358{ 367{
359 object *op = NULL; 368 object *op = NULL;
1083 * if the map isn't there, then stay on the 1092 * if the map isn't there, then stay on the
1084 * default initial map */ 1093 * default initial map */
1085 tmp->destroy (); 1094 tmp->destroy ();
1086 } 1095 }
1087 else 1096 else
1088 {
1089 LOG (llevDebug, "first_map_ext_path not set\n"); 1097 LOG (llevDebug, "first_map_ext_path not set\n");
1090 } 1098
1091 return 0; 1099 return 0;
1092 } 1100 }
1093 1101
1094 /* Following actually changes the race - this is the default command 1102 /* Following actually changes the race - this is the default command
1095 * if we don't match with one of the options above. 1103 * if we don't match with one of the options above.
1215 { 1223 {
1216 op->enemy = NULL; 1224 op->enemy = NULL;
1217 CLEAR_FLAG (op, FLAG_SCARED); 1225 CLEAR_FLAG (op, FLAG_SCARED);
1218 return; 1226 return;
1219 } 1227 }
1228
1220 get_rangevector (op, op->enemy, &rv, 0); 1229 get_rangevector (op, op->enemy, &rv, 0);
1221 1230
1222 dir = absdir (4 + rv.direction); 1231 dir = absdir (4 + rv.direction);
1223 for (diff = 0; diff < 3; diff++) 1232 for (diff = 0; diff < 3; diff++)
1224 { 1233 {
1225 int m = 1 - (RANDOM () & 2); 1234 int m = 1 - (RANDOM () & 2);
1226 1235
1227 if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op))) 1236 if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op)))
1228 {
1229 return; 1237 return;
1230 }
1231 } 1238 }
1239
1232 /* Cornered, get rid of scared */ 1240 /* Cornered, get rid of scared */
1233 CLEAR_FLAG (op, FLAG_SCARED); 1241 CLEAR_FLAG (op, FLAG_SCARED);
1234 op->enemy = NULL; 1242 op->enemy = NULL;
1235} 1243}
1236 1244
1792 if (!dir) 1800 if (!dir)
1793 { 1801 {
1794 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); 1802 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!");
1795 return 0; 1803 return 0;
1796 } 1804 }
1805
1797 if (op->type == PLAYER) 1806 if (op->type == PLAYER)
1798 bow = op->contr->ranges[range_bow]; 1807 bow = op->contr->ranges[range_bow];
1799 else 1808 else
1800 { 1809 {
1801 for (bow = op->inv; bow; bow = bow->below) 1810 for (bow = op->inv; bow; bow = bow->below)
1809 { 1818 {
1810 LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name); 1819 LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name);
1811 return 0; 1820 return 0;
1812 } 1821 }
1813 } 1822 }
1823
1814 if (!bow->race || !bow->skill) 1824 if (!bow->race || !bow->skill)
1815 { 1825 {
1816 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); 1826 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name);
1817 return 0; 1827 return 0;
1818 } 1828 }
1820 bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex]; 1830 bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex];
1821 1831
1822 /* penalize ROF for bestarrow */ 1832 /* penalize ROF for bestarrow */
1823 if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow) 1833 if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow)
1824 bowspeed -= dex_bonus[op->stats.Dex] + 5; 1834 bowspeed -= dex_bonus[op->stats.Dex] + 5;
1835
1825 if (bowspeed < 1) 1836 if (bowspeed < 1)
1826 bowspeed = 1; 1837 bowspeed = 1;
1827 1838
1828 if (arrow == NULL) 1839 if (arrow == NULL)
1829 { 1840 {
1835 else 1846 else
1836 CLEAR_FLAG (op, FLAG_READY_BOW); 1847 CLEAR_FLAG (op, FLAG_READY_BOW);
1837 return 0; 1848 return 0;
1838 } 1849 }
1839 } 1850 }
1851
1840 mflags = get_map_flags (op->map, &m, sx, sy, &sx, &sy); 1852 mflags = get_map_flags (op->map, &m, sx, sy, &sx, &sy);
1841 if (mflags & P_OUT_OF_MAP) 1853 if (mflags & P_OUT_OF_MAP)
1842 {
1843 return 0; 1854 return 0;
1844 } 1855
1845 if (GET_MAP_MOVE_BLOCK (m, sx, sy) == MOVE_FLY_LOW) 1856 if (GET_MAP_MOVE_BLOCK (m, sx, sy) == MOVE_FLY_LOW)
1846 { 1857 {
1847 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); 1858 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way.");
1848 return 0; 1859 return 0;
1849 } 1860 }
1855 return 0; 1866 return 0;
1856 } 1867 }
1857 1868
1858 left = arrow; /* these are arrows left to the player */ 1869 left = arrow; /* these are arrows left to the player */
1859 arrow = get_split_ob (arrow, 1); 1870 arrow = get_split_ob (arrow, 1);
1860 if (arrow == NULL) 1871 if (!arrow)
1861 { 1872 {
1862 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); 1873 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race);
1863 return 0; 1874 return 0;
1864 } 1875 }
1876
1865 arrow->set_owner (op); 1877 arrow->set_owner (op);
1866 arrow->skill = bow->skill; 1878 arrow->skill = bow->skill;
1867 1879
1868 arrow->direction = dir; 1880 arrow->direction = dir;
1869 arrow->x = sx; 1881 arrow->x = sx;
1912 } 1924 }
1913 1925
1914 if (arrow->attacktype == AT_PHYSICAL) 1926 if (arrow->attacktype == AT_PHYSICAL)
1915 arrow->attacktype |= bow->attacktype; 1927 arrow->attacktype |= bow->attacktype;
1916 1928
1917 if (bow->slaying != NULL) 1929 if (bow->slaying)
1918 arrow->slaying = bow->slaying; 1930 arrow->slaying = bow->slaying;
1919 1931
1920 arrow->map = m; 1932 arrow->map = m;
1921 arrow->move_type = MOVE_FLY_LOW; 1933 arrow->move_type = MOVE_FLY_LOW;
1922 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; 1934 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK;
2038 CLEAR_FLAG (item, FLAG_ANIMATE); 2050 CLEAR_FLAG (item, FLAG_ANIMATE);
2039 item->face = item->arch->clone.face; 2051 item->face = item->arch->clone.face;
2040 item->speed = 0; 2052 item->speed = 0;
2041 update_ob_speed (item); 2053 update_ob_speed (item);
2042 } 2054 }
2043 if ((tmp = is_player_inv (item))) 2055 if ((tmp = item->in_player ()))
2044 esrv_update_item (UPD_ANIM, tmp, item); 2056 esrv_update_item (UPD_ANIM, tmp, item);
2045 } 2057 }
2046 } 2058 }
2047 else if (item->type == ROD || item->type == HORN) 2059 else if (item->type == ROD || item->type == HORN)
2048 { 2060 {
2198 * 0 otherwise 2210 * 0 otherwise
2199 */ 2211 */
2200static int 2212static int
2201player_attack_door (object *op, object *door) 2213player_attack_door (object *op, object *door)
2202{ 2214{
2203
2204 /* If its a door, try to find a use a key. If we do destroy the door, 2215 /* If its a door, try to find a use a key. If we do destroy the door,
2205 * might as well return immediately as there is nothing more to do - 2216 * might as well return immediately as there is nothing more to do -
2206 * otherwise, we fall through to the rest of the code. 2217 * otherwise, we fall through to the rest of the code.
2207 */ 2218 */
2208 object *key = find_key (op, op, door); 2219 object *key = find_key (op, op, door);
2246 * It should keep the code cleaner. 2257 * It should keep the code cleaner.
2247 * When this is called, the players direction has been updated 2258 * When this is called, the players direction has been updated
2248 * (taking into account confusion.) The player is also actually 2259 * (taking into account confusion.) The player is also actually
2249 * going to try and move (not fire weapons). 2260 * going to try and move (not fire weapons).
2250 */ 2261 */
2251
2252void 2262void
2253move_player_attack (object *op, int dir) 2263move_player_attack (object *op, int dir)
2254{ 2264{
2255 object *tmp, *mon; 2265 object *tmp, *mon;
2256 sint16 nx, ny; 2266 sint16 nx, ny;
2258 maptile *m; 2268 maptile *m;
2259 2269
2260 nx = freearr_x[dir] + op->x; 2270 nx = freearr_x[dir] + op->x;
2261 ny = freearr_y[dir] + op->y; 2271 ny = freearr_y[dir] + op->y;
2262 2272
2263 on_battleground = op_on_battleground (op, NULL, NULL); 2273 on_battleground = op_on_battleground (op, 0, 0);
2264 2274
2265 /* If braced, or can't move to the square, and it is not out of the 2275 /* If braced, or can't move to the square, and it is not out of the
2266 * map, attack it. Note order of if statement is important - don't 2276 * map, attack it. Note order of if statement is important - don't
2267 * want to be calling move_ob if braced, because move_ob will move the 2277 * want to be calling move_ob if braced, because move_ob will move the
2268 * player. This is a pretty nasty hack, because if we could 2278 * player. This is a pretty nasty hack, because if we could
2280 return; /* Don't think this should happen */ 2290 return; /* Don't think this should happen */
2281 } 2291 }
2282 else 2292 else
2283 m = op->map; 2293 m = op->map;
2284 2294
2285 if ((tmp = get_map_ob (m, nx, ny)) == NULL) 2295 if ((tmp = GET_MAP_OB (m, nx, ny)) == NULL)
2286 { 2296 {
2287 /* LOG(llevError,"player_move_attack: get_map_ob returns NULL, but player can not more there.\n"); */ 2297 /* LOG(llevError,"player_move_attack: GET_MAP_OB returns NULL, but player can not move there.\n"); */
2288 return; 2298 return;
2289 } 2299 }
2290 2300
2291 mon = NULL; 2301 mon = 0;
2292 /* Go through all the objects, and find ones of interest. Only stop if 2302 /* Go through all the objects, and find ones of interest. Only stop if
2293 * we find a monster - that is something we know we want to attack. 2303 * we find a monster - that is something we know we want to attack.
2294 * if its a door or barrel (can roll) see if there may be monsters 2304 * if its a door or barrel (can roll) see if there may be monsters
2295 * on the space 2305 * on the space
2296 */ 2306 */
2297 while (tmp != NULL) 2307 while (tmp)
2298 { 2308 {
2299 if (tmp == op) 2309 if (tmp == op)
2300 { 2310 {
2301 tmp = tmp->above; 2311 tmp = tmp->above;
2302 continue; 2312 continue;
2312 mon = tmp; 2322 mon = tmp;
2313 2323
2314 tmp = tmp->above; 2324 tmp = tmp->above;
2315 } 2325 }
2316 2326
2317 if (mon == NULL) /* This happens anytime the player tries to move */ 2327 if (!mon) /* This happens anytime the player tries to move */
2318 return; /* into a wall */ 2328 return; /* into a wall */
2319 2329
2320 if (mon->head != NULL) 2330 if (mon->head)
2321 mon = mon->head; 2331 mon = mon->head;
2322 2332
2323 if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR)) 2333 if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR))
2324 if (player_attack_door (op, mon)) 2334 if (player_attack_door (op, mon))
2325 return; 2335 return;
2362 * attack them either. 2372 * attack them either.
2363 */ 2373 */
2364 if ((mon->type == PLAYER || mon->enemy != op) && 2374 if ((mon->type == PLAYER || mon->enemy != op) &&
2365 (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && ( 2375 (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && (
2366#ifdef PROHIBIT_PLAYERKILL 2376#ifdef PROHIBIT_PLAYERKILL
2367 (op->contr->peaceful 2377 (op->contr->peaceful
2368 || (mon->type == PLAYER 2378 || (mon->type == PLAYER
2369 && mon->contr-> 2379 && mon->contr->
2370 peaceful)) && 2380 peaceful)) &&
2371#else 2381#else
2372 op->contr->peaceful && 2382 op->contr->peaceful &&
2373#endif 2383#endif
2374 !on_battleground)) 2384 !on_battleground))
2375 { 2385 {
2376 if (!op->contr->braced) 2386 if (!op->contr->braced)
2377 { 2387 {
2378 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); 2388 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER);
2379 (void) push_ob (mon, dir, op); 2389 (void) push_ob (mon, dir, op);
2380 } 2390 }
2381 else 2391 else
2382 {
2383 new_draw_info (0, 0, op, "You withhold your attack"); 2392 new_draw_info (0, 0, op, "You withhold your attack");
2384 } 2393
2385 if (op->contr->tmp_invis || op->hide) 2394 if (op->contr->tmp_invis || op->hide)
2386 make_visible (op); 2395 make_visible (op);
2387 } 2396 }
2388 2397
2389 /* If the object is a boulder or other rollable object, then 2398 /* If the object is a boulder or other rollable object, then
2417 op->speed_left += op->speed / op->contr->weapon_sp; 2426 op->speed_left += op->speed / op->contr->weapon_sp;
2418 2427
2419 op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ 2428 op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */
2420 } 2429 }
2421 2430
2422 skill_attack (mon, op, 0, NULL, NULL); 2431 skill_attack (mon, op, 0, 0, 0);
2423 2432
2424 /* If attacking another player, that player gets automatic 2433 /* If attacking another player, that player gets automatic
2425 * hitback, and doesn't loose luck either. 2434 * hitback, and doesn't loose luck either.
2426 * Disable hitback on the battleground or if the target is 2435 * Disable hitback on the battleground or if the target is
2427 * the wiz. 2436 * the wiz.
2429 if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit && !on_battleground && !QUERY_FLAG (mon, FLAG_WIZ)) 2438 if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit && !on_battleground && !QUERY_FLAG (mon, FLAG_WIZ))
2430 { 2439 {
2431 short luck = mon->stats.luck; 2440 short luck = mon->stats.luck;
2432 2441
2433 mon->contr->has_hit = 1; 2442 mon->contr->has_hit = 1;
2434 skill_attack (op, mon, 0, NULL, NULL); 2443 skill_attack (op, mon, 0, 0, 0);
2435 mon->stats.luck = luck; 2444 mon->stats.luck = luck;
2436 } 2445 }
2446
2437 if (action_makes_visible (op)) 2447 if (action_makes_visible (op))
2438 make_visible (op); 2448 make_visible (op);
2439 } 2449 }
2440 } /* if player should attack something */ 2450 } /* if player should attack something */
2441} 2451}
2476 2486
2477 /* Add special check for newcs players and fire on - this way, the 2487 /* Add special check for newcs players and fire on - this way, the
2478 * server can handle repeat firing. 2488 * server can handle repeat firing.
2479 */ 2489 */
2480 if (op->contr->fire_on || (op->contr->run_on && pick != 0)) 2490 if (op->contr->fire_on || (op->contr->run_on && pick != 0))
2481 {
2482 op->direction = dir; 2491 op->direction = dir;
2483 }
2484 else 2492 else
2485 {
2486 op->direction = 0; 2493 op->direction = 0;
2487 } 2494
2488 /* Update how the player looks. Use the facing, so direction may 2495 /* Update how the player looks. Use the facing, so direction may
2489 * get reset to zero. This allows for full animation capabilities 2496 * get reset to zero. This allows for full animation capabilities
2490 * for players. 2497 * for players.
2491 */ 2498 */
2492 animate_object (op, op->facing); 2499 animate_object (op, op->facing);
2544 2551
2545 /* call this here - we also will call this in do_ericserver, but 2552 /* call this here - we also will call this in do_ericserver, but
2546 * the players time has been increased when doericserver has been 2553 * the players time has been increased when doericserver has been
2547 * called, so we recheck it here. 2554 * called, so we recheck it here.
2548 */ 2555 */
2549 op->contr->socket->handle_command (); 2556 //TODO: better than handling 8 commands, use some more intelligent rate-limiting
2557 for (int rep = 8; --rep && op->contr->socket->handle_command (); )
2558 ;
2559
2550 if (op->speed_left < 0) 2560 if (op->speed_left < 0)
2551 return 0; 2561 return 0;
2552 2562
2553 if (op->direction && (op->contr->run_on || op->contr->fire_on)) 2563 if (op->direction && (op->contr->run_on || op->contr->fire_on))
2554 { 2564 {
3213 * at his savebed location, and that can have long lasting 3223 * at his savebed location, and that can have long lasting
3214 * spell effects. So first see if there is a spell effect 3224 * spell effects. So first see if there is a spell effect
3215 * on the space that might harm the player. 3225 * on the space that might harm the player.
3216 */ 3226 */
3217 will_kill_again = 0; 3227 will_kill_again = 0;
3218 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) 3228 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above)
3219 if (tmp->type == SPELL_EFFECT) 3229 if (tmp->type == SPELL_EFFECT)
3220 will_kill_again |= tmp->attacktype; 3230 will_kill_again |= tmp->attacktype;
3221 3231
3222 if (will_kill_again) 3232 if (will_kill_again)
3223 { 3233 {
3320 } 3330 }
3321 3331
3322 for (tmp = op->inv; tmp != NULL; tmp = next) 3332 for (tmp = op->inv; tmp != NULL; tmp = next)
3323 { 3333 {
3324 next = tmp->below; 3334 next = tmp->below;
3325 if (tmp->type == EXPERIENCE || tmp->invisible) 3335 if (tmp->invisible)
3326 continue; 3336 continue;
3327 tmp->remove (); 3337 tmp->remove ();
3328 tmp->x = op->x, tmp->y = op->y; 3338 tmp->x = op->x, tmp->y = op->y;
3329 if (tmp->type == CONTAINER) 3339 if (tmp->type == CONTAINER)
3330 { /* empty container to ground */ 3340 { /* empty container to ground */
3436 object *tmp = NULL; 3446 object *tmp = NULL;
3437 3447
3438 if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD)) 3448 if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD))
3439 return 1; 3449 return 1;
3440 3450
3441 if (op->type == PLAYER)
3442 for (tmp = op->inv; tmp; tmp = tmp->below)
3443 if (tmp->type == EXPERIENCE && tmp->stats.Wis)
3444 if (QUERY_FLAG (tmp, FLAG_UNDEAD))
3445 return 1;
3446 return 0; 3451 return 0;
3447} 3452}
3448 3453
3449/* look at the surrounding terrain to determine 3454/* look at the surrounding terrain to determine
3450 * the hideability of this object. Positive levels 3455 * the hideability of this object. Positive levels
3565 if (mflags & P_OUT_OF_MAP) 3570 if (mflags & P_OUT_OF_MAP)
3566 continue; 3571 continue;
3567 if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y))) 3572 if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y)))
3568 continue; 3573 continue;
3569 3574
3570 for (tmp = get_map_ob (m, x, y); tmp; tmp = tmp->above) 3575 for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above)
3571 { 3576 {
3572 if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) 3577 if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE))
3573 return 1; 3578 return 1;
3574 else if (tmp->type == PLAYER) 3579 else if (tmp->type == PLAYER)
3575 { 3580 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines