Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. Board *tmpBoard = AllocBoard(*boardSize);
  2. free(boardSize);
  3.  
  4. Player *tmpPlayers[10];
  5. int tmpPenguinsMs[100], tmpPenguinsNs[100];
  6.  
  7. for (int i = 0; i < 100; ++i) {
  8. tmpPenguinsMs[i] = -1;
  9. tmpPenguinsNs[i] = -1;
  10. }
  11.  
  12. for (int k = 0; k < 10; ++k) {
  13. tmpPlayers[k] = NULL;
  14. }
  15.  
  16. for (int i = 0; i < m; ++i) {
  17. for (int j = 0; j < n; ++j) {
  18. char fieldStr[3];
  19. fscanf(file, "%s", fieldStr);
  20.  
  21. if (atoi(fieldStr) != 0){
  22. char c1[2], c2[2];
  23. c1[0] = fieldStr[0];
  24. c1[1] = '\0';
  25.  
  26. c2[0] = fieldStr[1];
  27. c2[1] = '\0';
  28.  
  29. int fishCount = atoi(c1);
  30. if (fishCount > 3){
  31. fclose(file);
  32. printf("Cannot place %d fish on the field (m = %d, n = %d).", fishCount, i, j);
  33. return 2;
  34. }
  35. tmpBoard->tiles[j][i]->numberOfFish = fishCount;
  36.  
  37. int playerInt = atoi(c2);
  38.  
  39. if (playerInt > 0){
  40. if (tmpPlayers[playerInt - 1] == NULL) {
  41. tmpPlayers[playerInt - 1] = AllocPlayer(gameSession);
  42. }
  43. tmpPenguinsMs[(playerInt - 1) * 10 + (tmpPlayers[(playerInt - 1)]->num_penguins)] = j;
  44. tmpPenguinsNs[(playerInt - 1) * 10 + (tmpPlayers[(playerInt - 1)]->num_penguins)] = i;
  45. tmpPlayers[(playerInt - 1)]->num_penguins++;
  46. }
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement