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.41 by root, Fri Dec 15 04:21:29 2006 UTC vs.
Revision 1.51 by root, Thu Dec 21 06:12:37 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines