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.144 by root, Sat May 26 15:44:08 2007 UTC vs.
Revision 1.148 by root, Mon Jun 4 12:19:09 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game 2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * Crossfire TRT is free software; you can redistribute it and/or modify it
9 * it under the terms of the GNU General Public License as published by 9 * under the terms of the GNU General Public License as published by the Free
10 * the Free Software Foundation; either version 2 of the License, or 10 * Software Foundation; either version 2 of the License, or (at your option)
11 * (at your option) any later version. 11 * any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful, but
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * GNU General Public License for more details. 16 * for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License along
19 * along with this program; if not, write to the Free Software 19 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * 21 *
22 * The author can be reached via e-mail to <crossfire@schmorp.de> 22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23 */ 23 */
24 24
25#include <global.h> 25#include <global.h>
26#include <sproto.h> 26#include <sproto.h>
27#include <sounds.h> 27#include <sounds.h>
207 ob->close_container (); //TODO: client-specific 207 ob->close_container (); //TODO: client-specific
208 208
209 ns->update_look = 0; 209 ns->update_look = 0;
210 ns->look_position = 0; 210 ns->look_position = 0;
211 211
212 clear_los (ob); 212 clear_los (this);
213 213
214 ns->reset_stats (); 214 ns->reset_stats ();
215 215
216 /* make sure he's a player -- needed because of class change. */ 216 /* make sure he's a player -- needed because of class change. */
217 ob->type = PLAYER; // we are paranoid 217 ob->type = PLAYER; // we are paranoid
232 shstr_cmp dragon_ability_force ("dragon_ability_force"); 232 shstr_cmp dragon_ability_force ("dragon_ability_force");
233 shstr_cmp dragon_skin_force ("dragon_skin_force"); 233 shstr_cmp dragon_skin_force ("dragon_skin_force");
234 234
235 for (tmp = ob->inv; tmp; tmp = tmp->below) 235 for (tmp = ob->inv; tmp; tmp = tmp->below)
236 if (tmp->type == FORCE) 236 if (tmp->type == FORCE)
237 if (tmp->arch->name == dragon_ability_force) 237 if (tmp->arch->archname == dragon_ability_force)
238 abil = tmp; 238 abil = tmp;
239 else if (tmp->arch->name == dragon_skin_force) 239 else if (tmp->arch->archname == dragon_skin_force)
240 skin = tmp; 240 skin = tmp;
241 241
242 set_dragon_name (ob, abil, skin); 242 set_dragon_name (ob, abil, skin);
243 } 243 }
244 244
311// the need for this function can be explained 311// the need for this function can be explained
312// by load_object not returning the object 312// by load_object not returning the object
313void 313void
314player::set_object (object *op) 314player::set_object (object *op)
315{ 315{
316 ob = op; 316 ob = observe = op;
317 ob->contr = this; /* this aren't yet in archetype */ 317 ob->contr = this; /* this aren't yet in archetype */
318 318
319 ob->speed = 1.0f; 319 ob->speed = 1.0f;
320 ob->speed_left = 0.5f; 320 ob->speed_left = 0.5f;
321 321
322 ob->direction = 5; /* So player faces south */ 322 ob->direction = 5; /* So player faces south */
323}
324
325void
326player::set_observe (object *op)
327{
328 observe = op ? op : ob;
329 do_los = 1;
323} 330}
324 331
325player::player () 332player::player ()
326{ 333{
327 /* There are some elements we want initialised to non zero value - 334 /* There are some elements we want initialised to non zero value -
907 if (*first_map_ext_path) 914 if (*first_map_ext_path)
908 { 915 {
909 object *tmp; 916 object *tmp;
910 char mapname[MAX_BUF]; 917 char mapname[MAX_BUF];
911 918
912 snprintf (mapname, MAX_BUF - 1, "%s/%s", &first_map_ext_path, &ob->arch->name); 919 snprintf (mapname, MAX_BUF - 1, "%s/%s", &first_map_ext_path, &ob->arch->archname);
913 tmp = object::create (); 920 tmp = object::create ();
914 EXIT_PATH (tmp) = mapname; 921 EXIT_PATH (tmp) = mapname;
915 EXIT_X (tmp) = ob->x; 922 EXIT_X (tmp) = ob->x;
916 EXIT_Y (tmp) = ob->y; 923 EXIT_Y (tmp) = ob->y;
917 ob->enter_exit (tmp); /* we don't really care if it succeeded; 924 ob->enter_exit (tmp); /* we don't really care if it succeeded;
1099 if (tmp->name != NULL) 1106 if (tmp->name != NULL)
1100 sprintf (putstring, "item name: %s item type: %d weight/value: %d", 1107 sprintf (putstring, "item name: %s item type: %d weight/value: %d",
1101 &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); 1108 &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))));
1102 else 1109 else
1103 sprintf (putstring, "item name: %s item type: %d weight/value: %d", 1110 sprintf (putstring, "item name: %s item type: %d weight/value: %d",
1104 &tmp->arch->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); 1111 &tmp->arch->archname, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))));
1105 1112
1106 new_draw_info (NDI_UNIQUE, 0, op, putstring); 1113 new_draw_info (NDI_UNIQUE, 0, op, putstring);
1107 } 1114 }
1108 1115
1109 /* philosophy: 1116 /* philosophy:
1302 /* careful: chairs and tables are weapons! */ 1309 /* careful: chairs and tables are weapons! */
1303 if (op->contr->mode & PU_ALLWEAPON) 1310 if (op->contr->mode & PU_ALLWEAPON)
1304 { 1311 {
1305 if (tmp->type == WEAPON && tmp->name != NULL) 1312 if (tmp->type == WEAPON && tmp->name != NULL)
1306 { 1313 {
1307 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && 1314 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->archname, "table") == NULL &&
1308 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) 1315 strstr (tmp->name, "chair") && strstr (tmp->arch->archname, "chair") == NULL)
1309 { 1316 {
1310 pick_up (op, tmp); 1317 pick_up (op, tmp);
1311 continue; 1318 continue;
1312 } 1319 }
1313 } 1320 }
1314 1321
1315 if (tmp->type == WEAPON && tmp->name == NULL) 1322 if (tmp->type == WEAPON && tmp->name == NULL)
1316 { 1323 {
1317 if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) 1324 if (strstr (tmp->arch->archname, "table") == NULL && strstr (tmp->arch->archname, "chair") == NULL)
1318 { 1325 {
1319 pick_up (op, tmp); 1326 pick_up (op, tmp);
1320 continue; 1327 continue;
1321 } 1328 }
1322 } 1329 }
1347 if (tmp->name != NULL) 1354 if (tmp->name != NULL)
1348 { 1355 {
1349 fprintf (stderr, "%s", tmp->name); 1356 fprintf (stderr, "%s", tmp->name);
1350 } 1357 }
1351 else 1358 else
1352 fprintf (stderr, "%s", tmp->arch->name); 1359 fprintf (stderr, "%s", tmp->arch->archname);
1353 fprintf (stderr, ",%d] = ", tmp->type); 1360 fprintf (stderr, ",%d] = ", tmp->type);
1354 fprintf (stderr, "%d\n", (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); 1361 fprintf (stderr, "%d\n", (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))));
1355#endif 1362#endif
1356 continue; 1363 continue;
1357 } 1364 }
3419 /* forces in the treasurelist can alter the player's stats */ 3426 /* forces in the treasurelist can alter the player's stats */
3420 object *skin; 3427 object *skin;
3421 3428
3422 /* first get the dragon skin force */ 3429 /* first get the dragon skin force */
3423 shstr_cmp dragon_skin_force ("dragon_skin_force"); 3430 shstr_cmp dragon_skin_force ("dragon_skin_force");
3424 for (skin = who->inv; skin && !(skin->arch->name == dragon_skin_force); skin = skin->below) 3431 for (skin = who->inv; skin && !(skin->arch->archname == dragon_skin_force); skin = skin->below)
3425 ; 3432 ;
3426 3433
3427 if (!skin) 3434 if (!skin)
3428 return; 3435 return;
3429 3436

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines