void Board::playerShooted() { if (_gameOver) return; int aimedRow = getAimedRow(_player.getPos(), _player.getDirection()); std::pair<Color, int> result = _rows[aimedRow].shoot(_player.getColor()); const Color newColor = result.first; const int ziiped = result.second; // evt to send pieces to other players in deathmatch SDL_Event event; event.type = EVT_PIECE; event.user.code = _id; _pendZiiped += ziiped; event.user.data1 = &_pendZiiped; SDL_PushEvent(&event); // to send pieces in net game _sentPieces += ziiped; bool newLevel = _score.addPoints(countPoints(ziiped)); if (newLevel) _timer.increaseSpeed(SpeedPercentInc); if (newColor != NoColor) { _player.reverse(); _player.setColor(newColor); } }
/** * Main control logic. * - processes a single CHM * - sets tciFlag indicating which tree crowns intersect the current CHM * - calls extractPoints */ static PyObject* Py_execute(PyObject* self, PyObject* args) { int xBlockPos, yBlockPos, bioFlag; char *inFile, *outFile, *outTiff; if(!PyArg_ParseTuple(args, "ssiiis", &inFile, &outFile, &xBlockPos, &yBlockPos, &bioFlag, &outTiff)) { PyErr_SetString(PyExc_IOError, "Py_execute could not parse parameters."); return NULL; } FILE * fpIn, * fpOut; if(!(fpIn = fopen(inFile, "r"))){ PyErr_SetString(PyExc_IOError, "Could not open input file."); return NULL; } if(!(fpOut = fopen(outFile, "w"))){ PyErr_SetString(PyExc_IOError, "Could not open output file."); return NULL; } int i, process, **numAll; double xBlockMin, xBlockMax, yBlockMin, yBlockMax; SHPObject * pShpObj; xBlockMin = MIN_E + (xBlockPos * BLOCK_SIZE); xBlockMax = xBlockMin + BLOCK_SIZE; yBlockMin = MIN_N + (yBlockPos * BLOCK_SIZE); yBlockMax = yBlockMin + BLOCK_SIZE; process = 0; //index all tree crowns that intersect the current file for(i = 0; i < N_RECORDS; i++) { if((pShpObj = SHPReadObject(H_SHP, i)) == NULL) { PyErr_SetString(PyExc_IOError, "Error opening shape file."); return NULL; } if(pShpObj->dfXMin >= xBlockMax || pShpObj->dfXMax <= xBlockMin || pShpObj->dfYMin >= yBlockMax || pShpObj->dfYMax <= yBlockMin) { tciFlag.data[i] = 0; } else{ process = 1; tciFlag.data[i] = 1; } SHPDestroyObject(pShpObj); } if(!process){ printf("Nothing to process\n"); return Py_None; } if(!readChm(fpIn)) return NULL; if(bioFlag) { numAll = countPoints(CHM, N_POINTS, MIN_E, MIN_N, BLOCK_SIZE, OUT_RES, xBlockPos, yBlockPos); if(!numAll) return NULL; int dim = BLOCK_SIZE/OUT_RES; int i,j; for(i = 0;i<dim;i++) for(j=0;j<dim;j++) printf("%d\n", numAll[i][j]); } //process each file for(i = 0; i < tciFlag.size; i++) { if(tciFlag.data[i] == 0)continue; printf("Calling:\textractPoints(%d, fpOut)\n", i); extractPoints(i, fpOut); } if(bioFlag) { printf("Run ccf calcs\n"); computeCCF(CHM, N_POINTS, numAll, MIN_E, MIN_N, BLOCK_SIZE, OUT_RES, Z_THRESH, xBlockPos, yBlockPos, outTiff); } printf("Calling:\twriteFile(fpOut, CHM, %d)\n", N_POINTS); if(!writeFile(fpOut, CHM, N_POINTS)) { return NULL; } freed2d(CHM, 3); free(POINT_CLASSIFICATION); fclose(fpIn); fclose(fpOut); return Py_None; }