Skip to content

Commit 904c624

Browse files
author
Roman
authored
Merge pull request #45 from nlinker/master
Use `cast_to_bw` and `cast_from_bw` for some type conversions
2 parents 444ae40 + 9b1e68f commit 904c624

24 files changed

+534
-478
lines changed

src/AIModule.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#include <AIModule.h>
2-
#include <BWAPI/AIModule.h>
3-
4-
#include "Position.hpp"
2+
#include "Cast.hpp"
53

64
class AIModuleWrapper : public BWAPI::AIModule
75
{
@@ -28,7 +26,7 @@ class AIModuleWrapper : public BWAPI::AIModule
2826
module->vtable->onPlayerLeft(module, reinterpret_cast<Player*>(player));
2927
}
3028
virtual void onNukeDetect(BWAPI::Position target) override {
31-
module->vtable->onNukeDetect(module, position_from_bw(target));
29+
module->vtable->onNukeDetect(module, cast_from_bw(target));
3230
}
3331
virtual void onUnitDiscover(BWAPI::Unit unit) override {
3432
module->vtable->onUnitDiscover(module, reinterpret_cast<Unit*>(unit));

src/Bullet.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
#include <Bullet.h>
2-
#include <BWAPI/Bullet.h>
3-
4-
#include "BulletType.hpp"
5-
#include "Position.hpp"
1+
#include "Cast.hpp"
62

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

1915
BulletType Bullet_getType(Bullet* self) {
20-
return bullettype_from_bw( reinterpret_cast<BWAPI::Bullet>(self)->getType() );
16+
return cast_from_bw( reinterpret_cast<BWAPI::Bullet>(self)->getType() );
2117
}
2218

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

2723
Position Bullet_getPosition(Bullet* self) {
28-
return position_from_bw( reinterpret_cast<BWAPI::Bullet>(self)->getPosition() );
24+
return cast_from_bw( reinterpret_cast<BWAPI::Bullet>(self)->getPosition() );
2925
}
3026

3127
double Bullet_getAngle(Bullet* self) {
@@ -45,7 +41,7 @@ Unit* Bullet_getTarget(Bullet* self) {
4541
}
4642

4743
Position Bullet_getTargetPosition(Bullet* self) {
48-
return position_from_bw( reinterpret_cast<BWAPI::Bullet>(self)->getTargetPosition() );
44+
return cast_from_bw( reinterpret_cast<BWAPI::Bullet>(self)->getTargetPosition() );
4945
}
5046

5147
int Bullet_getRemoveTimer(Bullet* self) {

src/BulletType.hpp

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)