void ResourceManager::processWavePatch(ResourceId resourceId, Common::String name) { ResourceSource *resSrc = new WaveResourceSource(name); Common::File file; file.open(name); updateResource(resourceId, resSrc, file.size()); debugC(1, kDebugLevelResMan, "Patching %s - OK", name.c_str()); }
void PropertyEdit::editingFinished() { if(m_label->fullText() != m_lineEdit->text()) { QString inputString = QLatin1String(m_lineEdit->text().toUtf8()); inputString = inputString.trimmed(); updateResource(inputString); setLabelText(m_lineEdit->text()); } m_lineEdit->hide(); m_label->show(); }
void ResourceRequester::readMessage() { QDataStream in(this); in.setVersion(QDataStream::Qt_4_7); quint32 new_version; if(nextBlockSize == 0) { if(bytesAvailable() < sizeof(quint32)) return; in >>nextBlockSize; if(0 == nextBlockSize) { qDebug()<<"-----------------------------------------------"; qDebug()<<"reource is the newest,do not need to update.."; qDebug()<<"-----------------------------------------------"; close(); return; } } if(bytesAvailable() < nextBlockSize) return; resource_list.clear(); in>>new_version>>resource_list; qDebug()<<"remote resource version change:"<<remote_res_peer.value() <<"->"<<new_version; remote_res_peer.value() = new_version; /* qDebug()<<"----------------------------------------------------------------"; qDebug()<<"----------------------------------------------------------------"; for(int i = 0; i < resource_list.size(); i++) { qDebug()<<">>>>resource id:"<<resource_list.at(i).id.toHex(); } qDebug()<<"----------------------------------------------------------------"; qDebug()<<"----------------------------------------------------------------"; */ t_ip_port rpc(peerAddress().toIPv4Address(), peerPort()); close(); updateResource(rpc); emit net_resource_list_update((QObject *)&resid2peer_map, (QObject*)&resid2pro_map); }
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; } } }
SFCurvesList* SFCurvesListData::buildResource() { SFCurvesList* curveList=new SFCurvesList(this->curves->size()); updateResource(curveList); return curveList; }
//平台从第1回合开始调用此函数获得每回合指令,请勿修改此函数声明。 extern "C" Order makeOrder(DataForAI data) { //printf("===================round%d tank%d==================\n",data.round,data.myID); Order order; order.type=STOP; mydata=data; updateResource(data); if(data.round==1&&data.myID==0) { assignResource(data); //getNext(data); } short range=data.tank[data.myID].range; //printf("range:%d\n",range); short vision=range; Point me; me.row=data.tank[data.myID].row; me.col=data.tank[data.myID].col; for(int i=-vision;i<=vision;i++) { for(int j=-vision;j<=vision;j++) { if(abs(i)+abs(j)<=vision)//in vision { short nr=me.row+i,nc=me.col+j; Point target; target.row=nr; target.col=nc; if(isInMap(nr,nc))//in map if(data.map[nr][nc].whoIsHere!=-1)//tank detected { short n=data.map[nr][nc].whoIsHere; if(data.tank[n].flag!=data.myFlag) { //printf("enemy tank%d\n",n); order.row=nr; order.col=nc; order.type=FIRE; return order; } } else if((data.map[nr][nc].type==BREAKBRICK||data.map[nr][nc].type==BRICK)&&isObstacle(target,nextStep[data.myID]))//bricks detected { //printf("tank%dbricks\n",data.myID); order.row=nr; order.col=nc; order.type=FIRE; return order; } } } } // //printf("the nearest point for tank%d (%d,%d)\n",data.myID,nearestS[data.myID].row,nearestS[data.myID].col); //assert(nearestS[data.myID].row>0); if(data.tank[data.myID].life!=0) { clock_t tstart,tend; float timeuse; tstart=clock(); if(data.map[nearestS[data.myID].row][nearestS[data.myID].col].isHereSource==RedSource||data.map[data.tank[data.myID].row][data.tank[data.myID].col].isHereSource==RedSource||nextStep[data.myID].empty()) { getNearestRS(data); } getNext(data); tend=clock(); timeuse=(tend-tstart)/CLOCKS_PER_SEC; //printf("round%d tank%dchange resource(%d,%d) and next step:(%d,%d),%f seconds used\n",data.round,data.myID,nearestS[data.myID].row,nearestS[data.myID].col,next[data.myID].row,next[data.myID].col,timeuse); }; /* if(data.map[next[data.myID].row][next[data.myID].col].whoIsHere!=-1||next[data.myID].row==-1) { while(1) { srand((int)time(0)); short i=rand()%4; short nr=data.tank[data.myID].row+dir[i][0],nc=data.tank[data.myID].col+dir[i][1]; if(data.map[nr][nc].type==PERVIOUS&&data.map[nr][nc].whoIsHere!=-1) { next[data.myID].row=nr; next[data.myID].col=nc; break; } } } */ short x=next[data.myID].row-data.tank[data.myID].row,y=next[data.myID].col-data.tank[data.myID].col; //printf("(x,y) for tank%d\n",x,y,data.myID); /*if(x<0)x=-1; else if(x>0)x=1; if(y<0)y=-1; else if(y>0)y=1;*/ for(int i=0;i<4;i++) { if(dir[i][0]==x&&dir[i][1]==y) { order.type=direction[i]; //printf("tank%d is going %s\n",data.myID,ds[i]); return order; } else { order.type=STOP; } //random step /* else { srand((int)time(0)); order.type=direction[rand()%4]; return order; }*/ } return order; }
SFBicurvedLoftedSurface* SFBicurvedLoftedSurfaceData::buildResource() { SFBicurvedLoftedSurface* loftCurve = new SFBicurvedLoftedSurface(); updateResource(loftCurve); return loftCurve; }