Checkpoints have a funny behaviour

Started by Shadow, Aug 12, 2016, 08:41 PM

Previous topic - Next topic

Shadow

#1
I was trying to implement checkpoints for a racing gamemode that I coded and I came up against this. Using spherical checkpoints, I tried to change their position. The server reported the position change but the checkpoint disappears upon entering it's radius and reappears in the new position only after I go out of the streaming range and return.

Proof of server managing to return proper position with code example below:

[spoiler]


int SphereCheckpoint::CreateCheckpoint(Player player, int32_t world, uint8_t isSphere, Vector3 position, RGBA colour, float radius)
{
if (this->b_Initialized)
{
OutputError("Error in SphereCheckpoint::CreateCheckpoint. Cannot intialize the same checkpoint twice.");
return -1;
}

if (!player.IsValid())
{
OutputError("Error in SphereCheckpoint::CreateCheckpoint. Player instance is invalid.");
return -1;
}

int checkpoint_id = gFuncs->CreateCheckPoint(player.GetPlayerID(), world, isSphere, position.x, position.y, position.z, colour.r, colour.g, colour.b, colour.a, radius);
if (checkpoint_id < 0)
{
OutputError("Error in SphereCheckpoint::CreateCheckpoint. %s.", GetErrorMessage(gFuncs->GetLastError()));
return -1;
}


this->b_Initialized = true;
this->nCheckpointId = checkpoint_id;
OutputInfo("Creating checkpoint at [%s] for player [%d] with radius [%.3f] with ID [%d].", static_cast<std::string>(position).c_str(), player.GetPlayerID(), radius, this->nCheckpointId);
return checkpoint_id;
}


vcmpError SphereCheckpoint::SetCheckpointPosition(Vector3 position)
{
if (!this->b_Initialized)
{
OutputError("Error in SphereCheckpoint::SetCheckpointPosition. Unitialized checkpoint.");
return vcmpError::vcmpErrorNoSuchEntity;
}

vcmpError error = gFuncs->SetCheckPointPosition(this->nCheckpointId, position.x, position.y, position.z);
if (error)
OutputMessage("Error in SphereCheckpoint::SetCheckpointPosition. %s", GetErrorMessage(error));

return error;
}
[/spoiler]



#2
I was trying to recreate and delete the checkpoints upon entering their radius but I came up against another funny issue which happens with spherical checkpoints and standard ones. Only 1/2 of the spherical checkpoints could be deleted and, despite calling the DeleteCheckpoint method from the plugin header, they would still trigger the OnCheckpointEntered event.

Proof below with video and code
[spoiler]
https://www.youtube.com/watch?v=2NSo24hltIY#

void SphereCheckpoint::Respawn(unsigned int playerID, int32_t world, Vector3 position, RGBA colour, float radius)
{
if(!this->b_Initialized)
{
OutputError("Error in SphereCheckpoint::SetCheckpointPosition. Unitialized checkpoint.");
return;
}


gFuncs->DeleteCheckPoint(this->nCheckpointId);
this->nCheckpointId = gFuncs->CreateCheckPoint(playerID, world, 0, position.x, position.y, position.z, colour.r, colour.g, colour.b, colour.a, radius);
}
[/spoiler]

#3
I was told spherical checkpoints tend to have such 'undefined' behaviour so I tried with standard checkpoints. Without success. Using the same chunk of code from above, the checkpoints would be half-invisible, non-deletable and some wouldn't even trigger the pick-up event.

Proof below with video:

[spoiler]https://youtu.be/yuEQCphtHYw[/spoiler]

As you can see in the last video, I even managed to pick up invisible checkpoints!

Must mention, no errors are thrown and, as you can clearly see, the checkpoints call the respective event. Some of them even come up on the map!

If anyone knows a better substitute for checkpoints (aside of 6 pickups), please let me know. Hope this report covers all the information needed to troubleshoot the issue.
QuotePS:is trash is ur home language??

Murdock


Shadow

Issue was confirmed by another player on another machine.
QuotePS:is trash is ur home language??

Shadow

Since it's still related to it (in some way, split if you want), I tried implementing race checkpoints with the usual 3x2 (XY, Z) set of pickups. However, guess what, the OnPickupPicked event does not get called fast enough. So if you're driving, pretty much any car you want, at full throttle, you might expect to have one checkpoint left behind, which is very frustrating.

Video of the issue:
https://www.youtube.com/watch?v=AU-F4NN5KPk&feature=youtu.be#

Code used to test:

void OnPickupClaimPicked(int nPickupId, int nPlayerId)
{
if (globalRaceSystem.HasStarted())
{
Player player = globalPlayerPool.GetPlayer(nPlayerId);
std::pair<Player, SphereCheckpoint> pairedCheckpoint = globalRaceSystem.GetPlayerCheckpointData(nPlayerId);

if (player.IsValid() && (player.GetPlayerID() == pairedCheckpoint.first.GetPlayerID()))
globalRaceSystem.ProcessCheckpoint(pairedCheckpoint.first);
}
}

... which always executes and has no trouble...
QuotePS:is trash is ur home language??

KAKAN

I can confirm that issue, it happens all the time.
oh no