Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Board *tmpBoard = AllocBoard(*boardSize);
- free(boardSize);
- Player *tmpPlayers[10];
- int tmpPenguinsMs[100], tmpPenguinsNs[100];
- for (int i = 0; i < 100; ++i) {
- tmpPenguinsMs[i] = -1;
- tmpPenguinsNs[i] = -1;
- }
- for (int k = 0; k < 10; ++k) {
- tmpPlayers[k] = NULL;
- }
- for (int i = 0; i < m; ++i) {
- for (int j = 0; j < n; ++j) {
- char fieldStr[3];
- fscanf(file, "%s", fieldStr);
- if (atoi(fieldStr) != 0){
- char c1[2], c2[2];
- c1[0] = fieldStr[0];
- c1[1] = '\0';
- c2[0] = fieldStr[1];
- c2[1] = '\0';
- int fishCount = atoi(c1);
- if (fishCount > 3){
- fclose(file);
- printf("Cannot place %d fish on the field (m = %d, n = %d).", fishCount, i, j);
- return 2;
- }
- tmpBoard->tiles[j][i]->numberOfFish = fishCount;
- int playerInt = atoi(c2);
- if (playerInt > 0){
- if (tmpPlayers[playerInt - 1] == NULL) {
- tmpPlayers[playerInt - 1] = AllocPlayer(gameSession);
- }
- tmpPenguinsMs[(playerInt - 1) * 10 + (tmpPlayers[(playerInt - 1)]->num_penguins)] = j;
- tmpPenguinsNs[(playerInt - 1) * 10 + (tmpPlayers[(playerInt - 1)]->num_penguins)] = i;
- tmpPlayers[(playerInt - 1)]->num_penguins++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement