Skip to content

Commit

Permalink
Global variable collisionWorld renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
ziggi committed Dec 25, 2018
1 parent a3dd415 commit efe2ec0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/CServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ BYTE CServer::Initialize(AMX *pAMX)

// Create the ColAndreas instance
m_pColAndreas = new ColAndreasWorld;
collisionWorld = m_pColAndreas;
if (collisionWorld->loadCollisionData()) {
gCollisionWorld = m_pColAndreas;
if (gCollisionWorld->loadCollisionData()) {
logprintf("Loaded collision data.");
colDataLoaded = true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ char szSampVersion[64];
bool colInit = false;
bool colDataLoaded = false;
cell nullAddress = NULL;
ColAndreasWorld *collisionWorld;
ColAndreasWorld *gCollisionWorld;

PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
{
Expand Down
2 changes: 1 addition & 1 deletion src/vendor/ColAndreas/DynamicWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ class ColAndreasWorld
btSequentialImpulseConstraintSolver* solver;
};

extern ColAndreasWorld* collisionWorld;
extern ColAndreasWorld* gCollisionWorld;

#endif
58 changes: 29 additions & 29 deletions src/vendor/ColAndreas/Natives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_Init(AMX *amx, cell *params)
if (colDataLoaded == true) {
if (colInit == false) {
logprintf("Loading Map.");
collisionWorld->colandreasInitMap();
gCollisionWorld->colandreasInitMap();
colInit = true;
logprintf("Loaded Map. ");
return 1;
Expand All @@ -36,7 +36,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_RayCastLine(AMX *amx, cell *params)
btVector3 Result;
uint16_t Model = 0;

if (collisionWorld->performRayTest(Start, End, Result, Model)) {
if (gCollisionWorld->performRayTest(Start, End, Result, Model)) {
//Get our adderesses for the last 3
amx_GetAddr(amx, params[7], &addr[0]);
amx_GetAddr(amx, params[8], &addr[1]);
Expand All @@ -62,7 +62,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_RayCastLineID(AMX *amx, cell *params)
btVector3 Result;
uint16_t Index = 0;

if (collisionWorld->performRayTestID(Start, End, Result, Index)) {
if (gCollisionWorld->performRayTestID(Start, End, Result, Index)) {
//Get our adderesses for the last 3
amx_GetAddr(amx, params[7], &addr[0]);
amx_GetAddr(amx, params[8], &addr[1]);
Expand All @@ -88,7 +88,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_RayCastLineExtraID(AMX *amx, cell *pa
btVector3 Result;
uint16_t Data = 0;

if (collisionWorld->performRayTestExtraID(Start, End, Result, params[1], Data)) {
if (gCollisionWorld->performRayTestExtraID(Start, End, Result, params[1], Data)) {
//Get our adderesses for the last 3
amx_GetAddr(amx, params[8], &addr[0]);
amx_GetAddr(amx, params[9], &addr[1]);
Expand Down Expand Up @@ -116,7 +116,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_RayCastLineEx(AMX *amx, cell *params)
btVector3 Result;
uint16_t Model = 0;

if (collisionWorld->performRayTestEx(Start, End, Result, Rotation, Position, Model)) {
if (gCollisionWorld->performRayTestEx(Start, End, Result, Rotation, Position, Model)) {
amx_GetAddr(amx, params[7], &addr[0]);
amx_GetAddr(amx, params[8], &addr[1]);
amx_GetAddr(amx, params[9], &addr[2]);
Expand Down Expand Up @@ -158,7 +158,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_RayCastLineAngle(AMX *amx, cell *para
btScalar RZ;
uint16_t model = 0;

if (collisionWorld->performRayTestAngle(Start, End, Result, RX, RY, RZ, model)) {
if (gCollisionWorld->performRayTestAngle(Start, End, Result, RX, RY, RZ, model)) {
//Get our adderesses for the last 6
amx_GetAddr(amx, params[7], &addr[0]);
amx_GetAddr(amx, params[8], &addr[1]);
Expand Down Expand Up @@ -195,7 +195,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_RayCastLineAngleEx(AMX *amx, cell *pa
btScalar RZ;
uint16_t Model = 0;

if (collisionWorld->performRayTestAngleEx(Start, End, Result, RX, RY, RZ, ObjectRotation, ObjectPosition, Model)) {
if (gCollisionWorld->performRayTestAngleEx(Start, End, Result, RX, RY, RZ, ObjectRotation, ObjectPosition, Model)) {
//Get our adderesses for the last 5
amx_GetAddr(amx, params[7], &addr[0]);
amx_GetAddr(amx, params[8], &addr[1]);
Expand Down Expand Up @@ -223,7 +223,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_RayCastLineAngleEx(AMX *amx, cell *pa
*addr[7] = amx_ftoc(ObjectPosition.getY());
*addr[8] = amx_ftoc(ObjectPosition.getZ());

collisionWorld->QuatToEuler(ObjectRotation, Result);
gCollisionWorld->QuatToEuler(ObjectRotation, Result);

*addr[9] = amx_ftoc(Result.getX());
*addr[10] = amx_ftoc(Result.getY());
Expand Down Expand Up @@ -253,7 +253,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_RayCastMultiLine(AMX *amx, cell *para
for (int i = 0; i < size; i++)
ModelIDs[i] = 0;

if (collisionWorld->performRayTestAll(Start, End, Result, ModelIDs, size)) {
if (gCollisionWorld->performRayTestAll(Start, End, Result, ModelIDs, size)) {
if (Result.size() <= size) {
cell *rawDataX = NULL;
cell *rawDataY = NULL;
Expand All @@ -272,7 +272,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_RayCastMultiLine(AMX *amx, cell *para
rawDataY[i] = amx_ftoc(Result[i].getY());
rawDataZ[i] = amx_ftoc(Result[i].getZ());

btScalar distance = collisionWorld->getDist3D(Start, btVector3(Result[i].getX(), Result[i].getY(), Result[i].getZ()));
btScalar distance = gCollisionWorld->getDist3D(Start, btVector3(Result[i].getX(), Result[i].getY(), Result[i].getZ()));
rawDataDist[i] = amx_ftoc(distance);
rawDataModel[i] = ModelIDs[i];
}
Expand All @@ -293,14 +293,14 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_CreateObject(AMX *amx, cell *params)
uint16_t modelid = static_cast<uint16_t>(params[1]);
uint16_t addtomanager = static_cast<uint16_t>(params[8]);

if (collisionWorld->getModelRef(modelid) != 65535) {
if (gCollisionWorld->getModelRef(modelid) != 65535) {
btVector3 position = btVector3(amx_ctof(params[2]), amx_ctof(params[3]), amx_ctof(params[4]));
btVector3 rotation = btVector3(amx_ctof(params[5]), amx_ctof(params[6]), amx_ctof(params[7]));

btQuaternion quatrotation;
collisionWorld->EulerToQuat(rotation, quatrotation);
gCollisionWorld->EulerToQuat(rotation, quatrotation);

return collisionWorld->createColAndreasMapObject(addtomanager, modelid, quatrotation, position);
return gCollisionWorld->createColAndreasMapObject(addtomanager, modelid, quatrotation, position);
}

// Model had no collision
Expand All @@ -313,15 +313,15 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_DestroyObject(AMX *amx, cell *params)
uint16_t index = static_cast<uint16_t>(params[1]);

if (index >= MAX_MAP_OBJECTS) return -1;
return collisionWorld->objectManager->removeObjectManager(index);
return gCollisionWorld->objectManager->removeObjectManager(index);
}

cell AMX_NATIVE_CALL ColAndreasNatives::CA_IsValidObject(AMX *amx, cell *params)
{
uint16_t index = static_cast<uint16_t>(params[1]);

if (index >= MAX_MAP_OBJECTS) return -1;
return collisionWorld->objectManager->validObjectManager(index);
return gCollisionWorld->objectManager->validObjectManager(index);
}

cell AMX_NATIVE_CALL ColAndreasNatives::CA_EulerToQuat(AMX *amx, cell *params)
Expand All @@ -332,7 +332,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_EulerToQuat(AMX *amx, cell *params)

btVector3 rotation = btVector3(amx_ctof(params[1]), amx_ctof(params[2]), amx_ctof(params[3]));

collisionWorld->EulerToQuat(rotation, Result);
gCollisionWorld->EulerToQuat(rotation, Result);

amx_GetAddr(amx, params[4], &addr[0]);
amx_GetAddr(amx, params[5], &addr[1]);
Expand All @@ -356,7 +356,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_QuatToEuler(AMX *amx, cell *params)

btQuaternion rotation = btQuaternion(amx_ctof(params[1]), amx_ctof(params[2]), amx_ctof(params[3]), amx_ctof(params[4]));

collisionWorld->QuatToEuler(rotation, Result);
gCollisionWorld->QuatToEuler(rotation, Result);

amx_GetAddr(amx, params[5], &addr[0]);
amx_GetAddr(amx, params[6], &addr[1]);
Expand All @@ -379,7 +379,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_RemoveBuilding(AMX *amx, cell *params
tmp.r_Y = amx_ctof(params[3]);
tmp.r_Z = amx_ctof(params[4]);
tmp.r_Radius = amx_ctof(params[5]);
collisionWorld->removedManager->addBuilding(tmp);
gCollisionWorld->removedManager->addBuilding(tmp);
return 1;
} else {
logprintf("ERROR: CA_RemoveBuilding : Map has already been initialized. Use this before CA_Init.");
Expand All @@ -391,16 +391,16 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_SetObjectPos(AMX *amx, cell *params)
{
uint16_t index = static_cast<uint16_t>(params[1]);
btVector3 position = btVector3(amx_ctof(params[2]), amx_ctof(params[3]), amx_ctof(params[4]));
return collisionWorld->objectManager->setObjectPosition(index, position);
return gCollisionWorld->objectManager->setObjectPosition(index, position);
}

cell AMX_NATIVE_CALL ColAndreasNatives::CA_SetObjectRot(AMX *amx, cell *params)
{
uint16_t index = static_cast<uint16_t>(params[1]);
btQuaternion result;
btVector3 rotation = btVector3(amx_ctof(params[2]), amx_ctof(params[3]), amx_ctof(params[4]));
collisionWorld->EulerToQuat(rotation, result);
return collisionWorld->objectManager->setObjectRotation(index, result);
gCollisionWorld->EulerToQuat(rotation, result);
return gCollisionWorld->objectManager->setObjectRotation(index, result);
}


Expand All @@ -412,7 +412,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_GetModelBoundingSphere(AMX *amx, cell
btScalar Radius;
btVector3 Center;

if (collisionWorld->objectManager->getBoundingSphere(modelid, Center, Radius)) {
if (gCollisionWorld->objectManager->getBoundingSphere(modelid, Center, Radius)) {
cell* addr[4];
amx_GetAddr(amx, params[2], &addr[0]);
amx_GetAddr(amx, params[3], &addr[1]);
Expand All @@ -439,7 +439,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_GetModelBoundingBox(AMX *amx, cell *p
btVector3 Min;
btVector3 Max;

if (collisionWorld->objectManager->getBoundingBox(modelid, Min, Max)) {
if (gCollisionWorld->objectManager->getBoundingBox(modelid, Min, Max)) {
cell* addr[6];
amx_GetAddr(amx, params[2], &addr[0]);
amx_GetAddr(amx, params[3], &addr[1]);
Expand All @@ -464,14 +464,14 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_GetModelBoundingBox(AMX *amx, cell *p
cell AMX_NATIVE_CALL ColAndreasNatives::CA_SetObjectExtraID(AMX *amx, cell *params)
{
uint16_t index = static_cast<uint16_t>(params[1]);
collisionWorld->setMyExtraID(index, params[2], params[3]);
gCollisionWorld->setMyExtraID(index, params[2], params[3]);
return 1;
}

cell AMX_NATIVE_CALL ColAndreasNatives::CA_GetObjectExtraID(AMX *amx, cell *params)
{
uint16_t index = static_cast<uint16_t>(params[1]);
return collisionWorld->getMyExtraID(index, params[2]);
return gCollisionWorld->getMyExtraID(index, params[2]);
}


Expand All @@ -487,7 +487,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_RayCastReflectionVector(AMX *amx, cel
btVector3 Position;
uint16_t model;

if (collisionWorld->performRayTestReflection(Start, End, Position, Result, model)) {
if (gCollisionWorld->performRayTestReflection(Start, End, Position, Result, model)) {
amx_GetAddr(amx, params[7], &addr[0]);
amx_GetAddr(amx, params[8], &addr[1]);
amx_GetAddr(amx, params[9], &addr[2]);
Expand Down Expand Up @@ -524,7 +524,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_RayCastLineNormal(AMX *amx, cell *par
btVector3 Position;
uint16_t model;

if (collisionWorld->performRayTestNormal(Start, End, Position, Result, model)) {
if (gCollisionWorld->performRayTestNormal(Start, End, Position, Result, model)) {
amx_GetAddr(amx, params[7], &addr[0]);
amx_GetAddr(amx, params[8], &addr[1]);
amx_GetAddr(amx, params[9], &addr[2]);
Expand Down Expand Up @@ -555,7 +555,7 @@ cell AMX_NATIVE_CALL ColAndreasNatives::CA_ContactTest(AMX *amx, cell *params)
btVector3 rotation = btVector3(amx_ctof(params[5]), amx_ctof(params[6]), amx_ctof(params[7]));

btQuaternion quatrotation;
collisionWorld->EulerToQuat(rotation, quatrotation);
gCollisionWorld->EulerToQuat(rotation, quatrotation);

return collisionWorld->performContactTest(modelid, position, quatrotation);
return gCollisionWorld->performContactTest(modelid, position, quatrotation);
}

0 comments on commit efe2ec0

Please sign in to comment.