Vice City: Multiplayer

VC:MP Discussion => Support => Bugs and Crashes => Topic started by: Shadow on Aug 12, 2016, 08:41 PM

Title: Checkpoints have a funny behaviour
Post by: Shadow on Aug 12, 2016, 08:41 PM
#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]
(https://i.gyazo.com/434a732b9304ba66a21d35e8e30a6c16.png)
(https://i.gyazo.com/b513c441a673a764f72b713981a38bc9.png)
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;
}

(https://i.gyazo.com/0732bb586334241f9ec46ddc642a1a63.png)
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#
(https://i.gyazo.com/f8b2435156a1f62f5693ced2a8cee698.png)
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.
Title: Re: Checkpoints have a funny behaviour
Post by: Murdock on Aug 12, 2016, 10:30 PM
Issue #1 is also already listed in the stickied list (http://forum.vc-mp.org/?topic=1377)
Title: Re: Checkpoints have a funny behaviour
Post by: Shadow on Aug 13, 2016, 08:02 PM
Issue was confirmed by another player on another machine.
Title: Re: Checkpoints have a funny behaviour
Post by: Shadow on Aug 13, 2016, 11:58 PM
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...
Title: Re: Checkpoints have a funny behaviour
Post by: KAKAN on Aug 14, 2016, 06:29 PM
I can confirm that issue, it happens all the time.