Commit c1ff6e0d9fccdebf4441148d32a2af05d963965f

Authored by Pedro L Coutin
1 parent 3647bea769
Exists in master

Dying works! But stuff is still really buggy. :(

Showing 3 changed files with 18 additions and 32 deletions Side-by-side Diff

client/main.c View file @ c1ff6e0
... ... @@ -189,7 +189,7 @@
189 189 }
190 190 else if (numready)
191 191 {
192   - unsigned char packet, hunter;
  192 + unsigned char packet;
193 193 unsigned char pnum, movx, movy;
194 194  
195 195 printf("srv socket is ready!!\n");
196 196  
... ... @@ -230,26 +230,9 @@
230 230 goto exit;
231 231 }
232 232 printf("Player %d deaded!!!!!\n", pnum);
233   - removep(choose_player(player,pnum));
  233 + removep(choose_player(player, pnum));
234 234 break;
235 235  
236   - case ADD_PLAYER:
237   - printf("ADD_PLAYER\n");
238   - hunter = addp(player,srv_sock);
239   - choose_hunter(player,hunter);
240   - me = choose_player(player,myno);
241   - draw_maze(MAZE.X, MAZE.Y);
242   -
243   - PLAYER *temp;
244   - for (temp = player->next; temp != NULL; temp = temp->next)
245   - {
246   - if (temp != NULL && temp->sprite != NULL)
247   - {
248   - printf("drew player %d\n", temp->playerno);
249   - drawPlayer(temp);
250   - }
251   - }
252   - break;
253 236 }
254 237 }
255 238 }
server/server.c View file @ c1ff6e0
... ... @@ -324,6 +324,9 @@
324 324 Player *coll;
325 325 int movPnum = justMoved->playerno;
326 326  
  327 + justMoved->x = x;
  328 + justMoved->y = y;
  329 +
327 330 /*
328 331 * If the player that just moved is a hunter, and it
329 332 * just stepped on a regular player, kill the (regular)
330 333  
331 334  
332 335  
333 336  
... ... @@ -471,21 +474,19 @@
471 474 short int
472 475 choose_hunter(Player_set *pset)
473 476 {
474   - int check = 0;
475 477 Player *temp;
476   - while (!check)
477   - {
478   - int hpno = mrand(1, pset->last_pno);
479 478  
480   - for (temp = pset->first; temp != NULL; temp = temp->next)
  479 + unsigned int hpno = mrand(1, pset->last_pno);
  480 +
  481 + for (temp = pset->first; temp != NULL; temp = temp->next)
  482 + {
  483 + if (temp->playerno == hpno)
481 484 {
482   - if (temp->playerno == hpno)
483   - {
484   - return hpno;
485   - }
  485 + temp->type = 1;
  486 + return hpno;
486 487 }
487 488 }
488   - return 0;
  489 + return -1;
489 490 }
490 491  
491 492  
492 493  
493 494  
... ... @@ -493,14 +494,14 @@
493 494 begin_game(Player_set *pset)
494 495 {
495 496 unsigned short magic;
  497 + unsigned char hpno;
496 498 int j = 0,i = 0;
497   - short int hpno = mrand(0, pset->last_pno);
498 499 Player *cur, *info;
499 500  
500 501 set_positions(pset);
501 502 printf("postions set!!\n");
502 503  
503   - choose_hunter(pset);
  504 + hpno = choose_hunter(pset);
504 505  
505 506 for (cur = pset->first; cur != NULL; cur = cur->next)
506 507 {
server/server.h View file @ c1ff6e0
... ... @@ -59,7 +59,9 @@
59 59 void rm_player(Player_set *set, Player *p);
60 60 Player *player_byfd(Player_set *s, int fd);
61 61 Player *player_byindex(Player_set *s, int fd);
62   -void pset_map(Player_set *s, void (*func)(), int fd, unsigned short sig);
  62 +void pset_map(Player_set *s,
  63 + void (*func)(Player *p, int a, unsigned short sig), int fd,
  64 + unsigned short sig);
63 65  
64 66 int mrand(int floor, int ceil);
65 67 void handle_connecting_player(int newfd, Player_set *pset);