void OptimizerVariableData::unassign( VariableID vid ) { assert( isAssigned( vid ) ); VarData & vd( get( vid ) ); vd.v->unassign(); setUnassigned( vid ); }
int _STDCALL m01 (void* ptr, EcMessageData* dIn, EcMessageData* dOut) { if (isAssigned (dIn)) { printf("m01 with text : %s\n", ecudc_asString(dIn->content)); } else { printf("m01 called\n"); } if (isAssigned (dOut)) { dOut->type = 0; dOut->content = ecudc_create (EC_ALLOC, ENTC_UDC_STRING, NULL); ecudc_setS (dOut->content, "Good 01"); } return 0; }
void CPetRoomsGlyph::selectGlyph(const Point &topLeft, const Point &pt) { if (isAssigned()) { bool isShiftPressed = g_vm->_window->getSpecialButtons() & MK_SHIFT; if (isShiftPressed) { int selection = getSelection(topLeft, pt); if (selection >= 0) _roomFlags |= 1 << selection; } updateTooltip(); } }
int _STDCALL c01 (void* ptr, EcMessageData* data, int errorcode) { if (isAssigned (data)) { printf("c01 with text : %s\n", ecudc_asString(data->content)); } else { printf("c01 called\n"); } return 0; }
// sets combat units to be passed to CombatCommander void GameCommander::setCombatUnits() { for (auto & unitTag : m_validUnits) { const sc2::Unit * unit = m_bot.GetUnit(unitTag); BOT_ASSERT(unit, "Have a null unit in our valid units\n"); if (!isAssigned(unitTag) && Util::IsCombatUnitType(unit->unit_type, m_bot)) { assignUnit(unitTag, m_combatUnits); } } }
int _STDCALL m02 (void* ptr, EcMessageData* dIn, EcMessageData* dOut) { if (isAssigned (dIn)) { printf("m02 with text : %s\n", ecudc_asString(dIn->content)); } else { printf("m02 called\n"); } if (isAssigned (dOut)) { dOut->type = 0; dOut->content = ecudc_create (EC_ALLOC, ENTC_UDC_STRING, NULL); ecudc_setS (dOut->content, "Good 02"); } printf("send m01 again\n"); ecmessages_send (0x01, 0x01, NULL, NULL); return 0; }
int _STDCALL module_callback_get (void* ptr, EcMessageData* dIn, EcMessageData* dOut) { if (isAssigned (dIn)) { switch (dIn->type) { case Q5_MSGTYPE_STATE_INIT: { return auth_checkF0 (ptr, dIn, dOut, module_getPath, ENTC_UDC_TABLEINFO); } case Q5_MSGTYPE_STATE_PROCESS: { return auth_processF1 (ptr, dIn, dOut, module_get, FALSE); } } } return ENTC_RESCODE_IGNORE; }
void getNearestRS(DataForAI& data) { updateResource(data); short min=MAP_HEIGHT+MAP_WIDTH; Point me; me.row=data.tank[data.myID].row; me.col=data.tank[data.myID].col; std::vector<Point>::iterator p; //assert(nS.empty()); for(std::vector<Point>::iterator i=nS.begin();i!=nS.end();i++) { printf("(%d,%d),",i->row,i->col); } printf("\n"); for(std::vector<Point>::iterator i=nS.begin();i!=nS.end();i++) { short tmp=estDistance(me,*i);//+estDangerous(*i,data)-estMyPower(me,data); if(min>tmp&&!isAssigned(*i,data)) { nearestS[data.myID]=*i; } } }
ENetPacket* gs_frame_createPacket (ubyte_t ch1, ubyte_t ch2, EcUdc node, int reliable) { ENetPacket* packet; unsigned char chh [2] = {ch1, ch2}; EcBuffer_s h = {chh, 2}; if (isAssigned (node)) { EcBuffer bins = ecbins_write (node, &h); packet = enet_packet_create (bins->buffer, bins->size, reliable ? ENET_PACKET_FLAG_RELIABLE : 0); ecbuf_destroy(&bins); } else { packet = enet_packet_create (chh, 2, reliable ? ENET_PACKET_FLAG_RELIABLE : 0); } /* unsigned char chh [8] = {ch1, ch2, 0, 0, 0, 0, 0, 0}; EcBuffer_s h = {chh, 8}; if (isAssigned (node)) { EcBuffer bins = ecbins_write (node, &h); if (bins->size < 255) // use 1 byte for len { bins->buffer [7] = bins->size; // shift the first 4 bytes by 2 bytes to right bins->buffer [6] = bins->buffer [3]; bins->buffer [5] = bins->buffer [2]; bins->buffer [4] = bins->buffer [1]; bins->buffer [3] = bins->buffer [0]; packet = enet_packet_create (bins->buffer + 3, bins->size - 3, reliable ? ENET_PACKET_FLAG_RELIABLE : 0); } else if (bins->size < 65536) // use 2 bytes for len { bins->buffer [2] |= C_BUFFER_SIZE_NORMAL; uint16_t* ptr = (uint16_t*)(bins->buffer + 6); *ptr = bins->size; // shift the first 4 bytes by 2 bytes to right bins->buffer [5] = bins->buffer [3]; bins->buffer [4] = bins->buffer [2]; bins->buffer [3] = bins->buffer [1]; bins->buffer [2] = bins->buffer [0]; packet = enet_packet_create (bins->buffer + 2, bins->size - 2, reliable ? ENET_PACKET_FLAG_RELIABLE : 0); } else // use 4 bytes for len { bins->buffer [2] |= C_BUFFER_SIZE_BIG; uint32_t* ptr = (uint32_t*)(bins->buffer + 4); *ptr = bins->size; packet = enet_packet_create (bins->buffer, bins->size, reliable ? ENET_PACKET_FLAG_RELIABLE : 0); } ecbuf_destroy(&bins); } else { chh [7] = 0; // shift the first 4 bytes by 2 bytes to right chh [6] = chh [3]; chh [5] = chh [2]; chh [4] = chh [1]; chh [3] = chh [0]; packet = enet_packet_create (chh, 5, reliable ? ENET_PACKET_FLAG_RELIABLE : 0); } */ return packet; }
void RoomThemeMaker::assignRoomThemes() { trace << "RoomThemeMaker::assignRoomThemes()..." << endl; for(int y = 0; y < MAP_H; y++) { for(int x = 0; x < MAP_W; x++) { themeMap[x][y] = RoomThemeId::plain; } } const int MIN_DIM = 3; const int MAX_DIM = 12; const int NR_NON_PLAIN_THEMED = Rnd::range(1, 4); vector<Room*>& rooms = eng.map->rooms; const int NR_ROOMS = rooms.size(); vector<bool> isAssigned(NR_ROOMS, false); trace << "RoomThemeMaker: Assigning plain theme to rooms with "; trace << "wrong dimensions" << endl; for(int i = 0; i < NR_ROOMS; i++) { Room* const r = rooms.at(i); // Check dimensions, assign plain if too small or too big if(isAssigned.at(i) == false) { const int W = r->getX1() - r->getX0() + 1; const int H = r->getY1() - r->getY0() + 1; if(W < MIN_DIM || W > MAX_DIM || H < MIN_DIM || H > MAX_DIM) { r->roomTheme = RoomThemeId::plain; isAssigned.at(i) = true; continue; } } } trace << "RoomThemeMaker: Trying to set non-plain themes "; trace << "for some rooms" << endl; bool blockers[MAP_W][MAP_H]; MapParse::parse(CellPred::BlocksMoveCmn(false, eng), blockers); const int NR_TRIES_TO_ASSIGN = 100; for(int i = 0; i < NR_NON_PLAIN_THEMED; i++) { for(int ii = 0; ii < NR_TRIES_TO_ASSIGN; ii++) { const int ELEMENT = Rnd::range(0, NR_ROOMS - 1); if(isAssigned.at(ELEMENT) == false) { const RoomThemeId theme = (RoomThemeId)(Rnd::range(1, int(RoomThemeId::endOfRoomThemes) - 1)); Room* const room = rooms.at(ELEMENT); if(isThemeAllowed(room, theme, blockers)) { room->roomTheme = theme; trace << "RoomThemeMaker: Assigned non-plain theme"; trace << "(" << int(theme) << ") to room" << endl; isAssigned.at(ELEMENT) = true; for(int y = room->getY0(); y < room->getY1(); y++) { for(int x = room->getX0(); x < room->getX1(); x++) { themeMap[x][y] = theme; } } break; } } } } trace << "RoomThemeMaker: Assigning plain theme to remaining rooms" << endl; for(int i = 0; i < NR_ROOMS; i++) { if(isAssigned.at(i) == false) { rooms.at(i)->roomTheme = RoomThemeId::plain; isAssigned.at(i) = true; } } trace << "RoomThemeMaker::assignRoomThemes() [DONE]" << endl; }