本文整理汇总了C++中DataReader::readInt方法的典型用法代码示例。如果您正苦于以下问题:C++ DataReader::readInt方法的具体用法?C++ DataReader::readInt怎么用?C++ DataReader::readInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataReader
的用法示例。
在下文中一共展示了DataReader::readInt方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readInit
void ClientSocket::readInit(DataReader r)
{
g.id = r.readInt();
cout<<"got ID "<<g.id<<'\n';
int w=r.readInt(), h=r.readInt();
Area& a=g.area;
a.w=w,a.h=h;
a.a = new int[w*h];
r.read(a.a, 4*w*h);
int b = r.readInt();
a.bases.resize(b);
r.read(&a.bases[0], 4*b);
cout<<"got map "<<a.w<<' '<<a.h<<'\n';
}
示例2: readName
void ClientSocket::readName(DataReader r){
int id = r.readInt();
char buf[33];
r.read(buf,32);
if(g.names.size()<=id)g.names.resize(id+20);
g.names[id] = buf;
std::cout<<id<<" is "<<buf<<"\n";
}
示例3: readItems
void ClientSocket::readItems(DataReader r)
{
int n=r.readInt();
Item it;
for(int i=0; i<n; ++i) {
r.read(&it, sizeof(it));
g.items_map.insert(it);
}
}
示例4: readLightning
void ClientSocket::readLightning(DataReader r)
{
int cnt = r.readInt();
vector<int> ids((int*)r.cur, ((int*)r.cur)+cnt);
g.lightnings.push_back(make_pair(0.0, ids));
double l = length(g.units[g.unitIndex[ids[0]]].loc - g.player->loc);
sounds.push_back(Sound(ELECTROSOUND, distvol(l)));
// cout<<"adding lightning "<<cnt<<'\n';
}
示例5: readDead
void ClientSocket::readDead(DataReader r){
int n = r.readInt();
for(int i=0;i<n;i++)
{
Unit u;
r.read(&u,sizeof(Unit));
u.shootTime = timef();
g.deadUnits.push_back(u);
}
}
示例6: readState
void ClientSocket::readState(DataReader r)
{
int n = r.readInt();
// cout<<"reading "<<n<<" units\n";
double d = g.player->d;
int mx=g.player->movex, my=g.player->movey;
g.units.resize(n);
memcpy(&g.units[0], r.cur, n*sizeof(Unit));
for(int i=0; i<n; ++i) g.units[i].id &= 0xffff;
for(int i=0; i<n; ++i) if (g.units[i].type==0 && g.units[i].id==g.id) {
Unit& u = g.units[i];
u.d=d;
u.movex = mx, u.movey = my;
break;
}
// Unit& u = g.units[0]; cout<<"jee "<<u.loc<<'\n';
}
示例7: readStats
void ClientSocket::readStats(DataReader r){
int n = r.readInt();
g.kills.clear();
g.teamkills.clear();
g.deaths.clear();
g.kills.resize(2000,-1);
g.teamkills.resize(2000,-1);
g.deaths.resize(2000,-1);
for(int i=0;i<n;i++)
{
int id = r.readInt();
if (id<0 || id>=g.kills.size()) {
for(int j=0; j<3; ++j) r.readInt();
continue;
}
g.kills[id]=r.readInt();
g.teamkills[id]=r.readInt();
g.deaths[id]=r.readInt();
}
}
示例8: readDestroyItem
void ClientSocket::readDestroyItem(DataReader r)
{
int id = r.readInt();
std::cout<<"readDestroyItem "<<id<<"\n";
g.items_map.remove(id);
}
示例9: readHit
void ClientSocket::readHit(DataReader r)
{
int id = r.readInt();
float x=r.readFloat(), y=r.readFloat();
g.destroyBullet(id,x,y);
}