1 | /* |
1 | /* |
2 | * static char *rcsid_player_c = |
2 | * static char *rcsid_player_c = |
3 | * "$Id: player.C,v 1.16 2006/09/05 18:18:09 root Exp $"; |
3 | * "$Id: player.C,v 1.17 2006/09/07 10:01:58 pippijn Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
60 | player* pl; |
60 | player* pl; |
61 | player* found = NULL; |
61 | player* found = NULL; |
62 | size_t namelen = strlen( plname ); |
62 | size_t namelen = strlen( plname ); |
63 | for ( pl = first_player; pl != NULL; pl = pl->next ) |
63 | for ( pl = first_player; pl != NULL; pl = pl->next ) |
64 | { |
64 | { |
65 | if ( strlen( pl->ob->name ) < namelen ) |
65 | if ( (size_t) strlen( pl->ob->name ) < namelen ) |
66 | continue; |
66 | continue; |
67 | |
67 | |
68 | if ( !strcmp( pl->ob->name, plname) ) |
68 | if ( !strcmp( pl->ob->name, plname) ) |
69 | return pl; |
69 | return pl; |
70 | |
70 | |
… | |
… | |
998 | /* This moves the player to a different start map, if there |
998 | /* This moves the player to a different start map, if there |
999 | * is one for this race |
999 | * is one for this race |
1000 | */ |
1000 | */ |
1001 | if(*first_map_ext_path) { |
1001 | if(*first_map_ext_path) { |
1002 | object *tmp; |
1002 | object *tmp; |
1003 | mapstruct *oldmap = op->map; |
|
|
1004 | char mapname[MAX_BUF]; |
1003 | char mapname[MAX_BUF]; |
1005 | snprintf(mapname, MAX_BUF-1, "%s/%s", |
1004 | snprintf(mapname, MAX_BUF-1, "%s/%s", |
1006 | first_map_ext_path, &op->arch->name); |
1005 | first_map_ext_path, &op->arch->name); |
1007 | tmp=get_object(); |
1006 | tmp=get_object(); |
1008 | EXIT_PATH(tmp) = mapname; |
1007 | EXIT_PATH(tmp) = mapname; |
… | |
… | |
1409 | { |
1408 | { |
1410 | /* use value density to decide what else to grab */ |
1409 | /* use value density to decide what else to grab */ |
1411 | /* >=7 was >= op->contr->mode */ |
1410 | /* >=7 was >= op->contr->mode */ |
1412 | /* >=7 is the old standard setting. Now we take the last 4 bits |
1411 | /* >=7 is the old standard setting. Now we take the last 4 bits |
1413 | * and multiply them by 5, giving 0..15*5== 5..75 */ |
1412 | * and multiply them by 5, giving 0..15*5== 5..75 */ |
1414 | wvratio=(op->contr->mode & PU_RATIO) * 5; |
1413 | wvratio = (op->contr->mode & PU_RATIO) * 5; |
1415 | if ((query_cost(tmp, op, F_TRUE)*100 / (tmp->weight * MAX(tmp->nrof, 1))) >= wvratio) |
1414 | if ((query_cost(tmp, op, F_TRUE) * 100 / (tmp->weight * MAX(tmp->nrof, 1))) >= (unsigned int) wvratio) |
1416 | { |
1415 | { |
1417 | pick_up(op, tmp); |
1416 | pick_up(op, tmp); |
1418 | #if 0 |
1417 | #if 0 |
1419 | fprintf(stderr,"HIGH WEIGHT/VALUE ["); |
1418 | fprintf(stderr,"HIGH WEIGHT/VALUE ["); |
1420 | if(tmp->name!=NULL) { |
1419 | if(tmp->name!=NULL) { |
… | |
… | |
2392 | int rate_grace = 2000; |
2391 | int rate_grace = 2000; |
2393 | const int max_hp = 1; |
2392 | const int max_hp = 1; |
2394 | const int max_sp = 1; |
2393 | const int max_sp = 1; |
2395 | const int max_grace = 1; |
2394 | const int max_grace = 1; |
2396 | |
2395 | |
2397 | if (op->contr->outputs_sync) { |
2396 | if (op->contr->outputs_sync) |
|
|
2397 | { |
2398 | for (i=0; i<NUM_OUTPUT_BUFS; i++) |
2398 | for (i=0; i<NUM_OUTPUT_BUFS; i++) |
2399 | if (op->contr->outputs[i].buf!=NULL && |
2399 | if (op->contr->outputs[i].buf!=NULL && |
2400 | (op->contr->outputs[i].first_update+op->contr->outputs_sync)<pticks) |
2400 | (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks) |
2401 | flush_output_element(op, &op->contr->outputs[i]); |
2401 | flush_output_element(op, &op->contr->outputs[i]); |
2402 | } |
2402 | } |
2403 | |
2403 | |
2404 | if(op->contr->state==ST_PLAYING) { |
2404 | if(op->contr->state==ST_PLAYING) { |
2405 | |
2405 | |
2406 | /* these next three if clauses make it possible to SLOW DOWN |
2406 | /* these next three if clauses make it possible to SLOW DOWN |
2407 | hp/grace/spellpoint regeneration. */ |
2407 | hp/grace/spellpoint regeneration. */ |
… | |
… | |
2564 | * file. |
2564 | * file. |
2565 | */ |
2565 | */ |
2566 | void kill_player(object *op) |
2566 | void kill_player(object *op) |
2567 | { |
2567 | { |
2568 | char buf[MAX_BUF]; |
2568 | char buf[MAX_BUF]; |
2569 | int x,y,i; |
2569 | int x, y; |
|
|
2570 | //int i; |
2570 | mapstruct *map; /* this is for resurrection */ |
2571 | mapstruct *map; /* this is for resurrection */ |
2571 | int z; |
2572 | /* int z; |
2572 | int num_stats_lose; |
2573 | int num_stats_lose; |
2573 | int lost_a_stat; |
2574 | int lost_a_stat; |
2574 | int lose_this_stat; |
2575 | int lose_this_stat; |
2575 | int this_stat; |
2576 | int this_stat; */ |
2576 | int will_kill_again; |
2577 | int will_kill_again; |
2577 | archetype *at; |
2578 | archetype *at; |
2578 | object *tmp; |
2579 | object *tmp; |
2579 | |
2580 | |
2580 | if(save_life(op)) |
2581 | if(save_life(op)) |