Skip to content

Commit

Permalink
Merge pull request #45 from nlinker/master
Browse files Browse the repository at this point in the history
Use `cast_to_bw` and `cast_from_bw` for some type conversions
  • Loading branch information
kpp authored Jun 11, 2017
2 parents 444ae40 + 9b1e68f commit 904c624
Show file tree
Hide file tree
Showing 24 changed files with 534 additions and 478 deletions.
6 changes: 2 additions & 4 deletions src/AIModule.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include <AIModule.h>
#include <BWAPI/AIModule.h>

#include "Position.hpp"
#include "Cast.hpp"

class AIModuleWrapper : public BWAPI::AIModule
{
Expand All @@ -28,7 +26,7 @@ class AIModuleWrapper : public BWAPI::AIModule
module->vtable->onPlayerLeft(module, reinterpret_cast<Player*>(player));
}
virtual void onNukeDetect(BWAPI::Position target) override {
module->vtable->onNukeDetect(module, position_from_bw(target));
module->vtable->onNukeDetect(module, cast_from_bw(target));
}
virtual void onUnitDiscover(BWAPI::Unit unit) override {
module->vtable->onUnitDiscover(module, reinterpret_cast<Unit*>(unit));
Expand Down
12 changes: 4 additions & 8 deletions src/Bullet.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#include <Bullet.h>
#include <BWAPI/Bullet.h>

#include "BulletType.hpp"
#include "Position.hpp"
#include "Cast.hpp"

int Bullet_getID(Bullet* self) {
return reinterpret_cast<BWAPI::Bullet>(self)->getID();
Expand All @@ -17,15 +13,15 @@ Player* Bullet_getPlayer(Bullet* self) {
}

BulletType Bullet_getType(Bullet* self) {
return bullettype_from_bw( reinterpret_cast<BWAPI::Bullet>(self)->getType() );
return cast_from_bw( reinterpret_cast<BWAPI::Bullet>(self)->getType() );
}

Unit* Bullet_getSource(Bullet* self) {
return reinterpret_cast<Unit*>( reinterpret_cast<BWAPI::Bullet>(self)->getSource() );
}

Position Bullet_getPosition(Bullet* self) {
return position_from_bw( reinterpret_cast<BWAPI::Bullet>(self)->getPosition() );
return cast_from_bw( reinterpret_cast<BWAPI::Bullet>(self)->getPosition() );
}

double Bullet_getAngle(Bullet* self) {
Expand All @@ -45,7 +41,7 @@ Unit* Bullet_getTarget(Bullet* self) {
}

Position Bullet_getTargetPosition(Bullet* self) {
return position_from_bw( reinterpret_cast<BWAPI::Bullet>(self)->getTargetPosition() );
return cast_from_bw( reinterpret_cast<BWAPI::Bullet>(self)->getTargetPosition() );
}

int Bullet_getRemoveTimer(Bullet* self) {
Expand Down
14 changes: 0 additions & 14 deletions src/BulletType.hpp

This file was deleted.

Loading

0 comments on commit 904c624

Please sign in to comment.