minor fixes
This commit is contained in:
parent
1006f94ba0
commit
89a4b6ffb2
@ -399,7 +399,7 @@ void Client::initialize(Arguments &arg) {
|
|||||||
|
|
||||||
if (isMaster()) {
|
if (isMaster()) {
|
||||||
Team *team = game.getTeam(0);
|
Team *team = game.getTeam(0);
|
||||||
game.local_player = game.spawn_player(team);
|
game.local_player = game.spawnPlayer(team);
|
||||||
std::cout << "[Game] local player " << game.local_player->id
|
std::cout << "[Game] local player " << game.local_player->id
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
@ -102,6 +102,9 @@ void Game::loadLevelShape() {
|
|||||||
levelMesh = tlLoadTrimesh("data/level.obj", TL_FVF_XYZ | TL_FVF_UV
|
levelMesh = tlLoadTrimesh("data/level.obj", TL_FVF_XYZ | TL_FVF_UV
|
||||||
| TL_FVF_NORMAL);
|
| TL_FVF_NORMAL);
|
||||||
|
|
||||||
|
if (levelMesh == 0)
|
||||||
|
throw("level mesh not found! (data/level.obj)");
|
||||||
|
|
||||||
btIndexedMesh im;
|
btIndexedMesh im;
|
||||||
im.m_numTriangles = levelMesh->face_count;
|
im.m_numTriangles = levelMesh->face_count;
|
||||||
im.m_triangleIndexBase = (unsigned char *) levelMesh->faces;
|
im.m_triangleIndexBase = (unsigned char *) levelMesh->faces;
|
||||||
@ -120,8 +123,6 @@ void Game::loadLevelShape() {
|
|||||||
btVector3 center;
|
btVector3 center;
|
||||||
btScalar radius;
|
btScalar radius;
|
||||||
_levelShape->getBoundingSphere(center, radius);
|
_levelShape->getBoundingSphere(center, radius);
|
||||||
std::cout << center.x() << " " << center.y() << " " << center.y() << ", "
|
|
||||||
<< radius << std::endl;
|
|
||||||
levelShape.reset(_levelShape);
|
levelShape.reset(_levelShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +219,7 @@ player_t *Game::getFreePlayer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player_t *Game::spawn_player(Team *team) {
|
player_t *Game::spawnPlayer(Team *team) {
|
||||||
player_t *player = getFreePlayer();
|
player_t *player = getFreePlayer();
|
||||||
player->team = team;
|
player->team = team;
|
||||||
player->status = 1;
|
player->status = 1;
|
||||||
@ -226,7 +227,7 @@ player_t *Game::spawn_player(Team *team) {
|
|||||||
reset_player(player);
|
reset_player(player);
|
||||||
|
|
||||||
if (player->body.get() == 0) {
|
if (player->body.get() == 0) {
|
||||||
std::cout << "Game::spawn_player: create body" << std::endl;
|
std::cout << "[Game] create body" << std::endl;
|
||||||
/// Create Dynamic Objects
|
/// Create Dynamic Objects
|
||||||
btTransform startTransform;
|
btTransform startTransform;
|
||||||
startTransform.setIdentity();
|
startTransform.setIdentity();
|
||||||
@ -245,7 +246,7 @@ player_t *Game::spawn_player(Team *team) {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
player_t *Game::spawn_player_id(Team *team, uint16_t id) {
|
player_t *Game::spawnPlayerWithId(Team *team, uint16_t id) {
|
||||||
player_t *player = getFreePlayer();
|
player_t *player = getFreePlayer();
|
||||||
player->team = team;
|
player->team = team;
|
||||||
player->id = id;
|
player->id = id;
|
||||||
|
@ -79,8 +79,8 @@ public:
|
|||||||
void setup();
|
void setup();
|
||||||
void reset();
|
void reset();
|
||||||
Team *team_with_least_players();
|
Team *team_with_least_players();
|
||||||
player_t *spawn_player(Team *team);
|
player_t *spawnPlayer(Team *team);
|
||||||
player_t *spawn_player_id(Team *team, uint16_t id);
|
player_t *spawnPlayerWithId(Team *team, uint16_t id);
|
||||||
Team *getTeam(uint16_t id);
|
Team *getTeam(uint16_t id);
|
||||||
player_t *getPlayer(uint16_t id);
|
player_t *getPlayer(uint16_t id);
|
||||||
bomb_t *getBomb(uint16_t index);
|
bomb_t *getBomb(uint16_t index);
|
||||||
|
@ -114,7 +114,7 @@ void Network::dispatch(enet_uint8 *data, size_t length) {
|
|||||||
case MESSAGE_PLAYER_SPAWN: {
|
case MESSAGE_PLAYER_SPAWN: {
|
||||||
player_spawn_message_t *sm = (player_spawn_message_t *) data;
|
player_spawn_message_t *sm = (player_spawn_message_t *) data;
|
||||||
Team *team = game->getTeam(sm->team_id);
|
Team *team = game->getTeam(sm->team_id);
|
||||||
player_t *player = game->spawn_player_id(team, sm->player_id);
|
player_t *player = game->spawnPlayerWithId(team, sm->player_id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MESSAGE_PLAYER_KILL: {
|
case MESSAGE_PLAYER_KILL: {
|
||||||
@ -132,7 +132,6 @@ void Network::dispatch(enet_uint8 *data, size_t length) {
|
|||||||
}
|
}
|
||||||
case MESSAGE_PLAYER_UPDATE: {
|
case MESSAGE_PLAYER_UPDATE: {
|
||||||
player_update_message_t *um = (player_update_message_t *) data;
|
player_update_message_t *um = (player_update_message_t *) data;
|
||||||
std::cout << "[Network] update player " << um->player_id << std::endl;
|
|
||||||
player_t *player = game->getPlayer(um->player_id);
|
player_t *player = game->getPlayer(um->player_id);
|
||||||
#if 1
|
#if 1
|
||||||
btVector3 v = player->body->getLinearVelocity();
|
btVector3 v = player->body->getLinearVelocity();
|
||||||
@ -271,7 +270,7 @@ void Network::service(uint32_t timeout) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Team *team = game->team_with_least_players();
|
Team *team = game->team_with_least_players();
|
||||||
player_t *player = game->spawn_player(team);
|
player_t *player = game->spawnPlayer(team);
|
||||||
event.peer->data = player;
|
event.peer->data = player;
|
||||||
|
|
||||||
// send player spawn message
|
// send player spawn message
|
||||||
|
Loading…
Reference in New Issue
Block a user