mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 09:01:57 -05:00
Add NotifyPositionAction CPE packet
After some reflection, I think having a separate packet for position actions would be more useful than packing the data into one cc_uint16 value.
This commit is contained in:
parent
ce409304c4
commit
6a51ab9215
3 changed files with 27 additions and 8 deletions
|
@ -801,6 +801,7 @@ static void LocalPlayers_OnNewMap(void) {
|
|||
}
|
||||
|
||||
static cc_bool LocalPlayer_IsSolidCollide(BlockID b) { return Blocks.Collide[b] == COLLIDE_SOLID; }
|
||||
|
||||
static void LocalPlayer_DoRespawn(struct LocalPlayer* p) {
|
||||
struct LocationUpdate update;
|
||||
struct AABB bb;
|
||||
|
@ -830,6 +831,9 @@ static void LocalPlayer_DoRespawn(struct LocalPlayer* p) {
|
|||
}
|
||||
}
|
||||
|
||||
struct EntityLocation* prev = &p->Base.prev;
|
||||
CPE_SendNotifyPositionAction(3, prev->pos.x, prev->pos.y, prev->pos.z);
|
||||
|
||||
/* Adjust the position to be slightly above the ground, so that */
|
||||
/* it's obvious to the player that they are being respawned */
|
||||
spawn.y += 2.0f/16.0f;
|
||||
|
@ -845,8 +849,6 @@ static void LocalPlayer_DoRespawn(struct LocalPlayer* p) {
|
|||
Entity_GetBounds(&p->Base, &bb);
|
||||
bb.Min.y -= 0.01f; bb.Max.y = bb.Min.y;
|
||||
p->Base.OnGround = Entity_TouchesAny(&bb, LocalPlayer_IsSolidCollide);
|
||||
|
||||
CPE_SendNotifyAction(3, 0);
|
||||
}
|
||||
|
||||
static cc_bool LocalPlayer_HandleRespawn(int key, struct InputDevice* device) {
|
||||
|
@ -888,7 +890,7 @@ static cc_bool LocalPlayer_HandleSetSpawn(int key, struct InputDevice* device) {
|
|||
p->SpawnYaw = p->Base.Yaw;
|
||||
if (!Game_ClassicMode) p->SpawnPitch = p->Base.Pitch;
|
||||
|
||||
CPE_SendNotifyAction(4, 0);
|
||||
CPE_SendNotifyPositionAction(4, p->Spawn.x, p->Spawn.y, p->Spawn.z);
|
||||
}
|
||||
return LocalPlayer_HandleRespawn(key, device);
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ static struct CpeExt
|
|||
lightingMode_Ext = { "LightingMode", 1 },
|
||||
cinematicGui_Ext = { "CinematicGui", 1 },
|
||||
notifyAction_Ext = { "NotifyAction", 1 },
|
||||
notifyPositionAction_Ext = { "NotifyPositionAction", 1 },
|
||||
extTextures_Ext = { "ExtendedTextures", 1 },
|
||||
extBlocks_Ext = { "ExtendedBlocks", 1 };
|
||||
|
||||
|
@ -104,6 +105,7 @@ static struct CpeExt* cpe_clientExtensions[] = {
|
|||
&blockDefsExt_Ext, &bulkBlockUpdate_Ext, &textColors_Ext, &envMapAspect_Ext, &entityProperty_Ext, &extEntityPos_Ext,
|
||||
&twoWayPing_Ext, &invOrder_Ext, &instantMOTD_Ext, &fastMap_Ext, &setHotbar_Ext, &setSpawnpoint_Ext, &velControl_Ext,
|
||||
&customParticles_Ext, &pluginMessages_Ext, &extTeleport_Ext, &lightingMode_Ext, &cinematicGui_Ext, ¬ifyAction_Ext,
|
||||
¬ifyPositionAction_Ext,
|
||||
#ifdef CUSTOM_MODELS
|
||||
&customModels_Ext,
|
||||
#endif
|
||||
|
@ -897,15 +899,28 @@ void CPE_SendPluginMessage(cc_uint8 channel, cc_uint8* data) {
|
|||
Server.SendData(buffer, 66);
|
||||
}
|
||||
|
||||
void CPE_SendNotifyAction(int action, cc_uint32 value) {
|
||||
cc_uint8 data[8];
|
||||
void CPE_SendNotifyAction(int action, cc_uint16 value) {
|
||||
cc_uint8 data[5];
|
||||
|
||||
data[0] = OPCODE_NOTIFY_ACTION;
|
||||
{
|
||||
Stream_SetU16_BE(data + 1, action);
|
||||
Stream_SetU32_BE(data + 3, value);
|
||||
Stream_SetU16_BE(data + 3, value);
|
||||
}
|
||||
Server.SendData(data, 8);
|
||||
Server.SendData(data, 5);
|
||||
}
|
||||
|
||||
void CPE_SendNotifyPositionAction(int action, int x, int y, int z) {
|
||||
cc_uint8 data[9];
|
||||
|
||||
data[0] = OPCODE_NOTIFY_POSITION_ACTION;
|
||||
{
|
||||
Stream_SetU16_BE(data + 1, action);
|
||||
Stream_SetU16_BE(data + 3, x);
|
||||
Stream_SetU16_BE(data + 5, y);
|
||||
Stream_SetU16_BE(data + 7, z);
|
||||
}
|
||||
Server.SendData(data, 9);
|
||||
}
|
||||
|
||||
static void CPE_SendExtInfo(int extsCount) {
|
||||
|
|
|
@ -40,6 +40,7 @@ enum OPCODE_ {
|
|||
OPCODE_DEFINE_MODEL, OPCODE_DEFINE_MODEL_PART, OPCODE_UNDEFINE_MODEL,
|
||||
OPCODE_PLUGIN_MESSAGE, OPCODE_ENTITY_TELEPORT_EXT,
|
||||
OPCODE_LIGHTING_MODE, OPCODE_CINEMATIC_GUI, OPCODE_NOTIFY_ACTION,
|
||||
OPCODE_NOTIFY_POSITION_ACTION,
|
||||
|
||||
OPCODE_COUNT
|
||||
};
|
||||
|
@ -71,7 +72,8 @@ void Classic_SendChat(const cc_string* text, cc_bool partial);\
|
|||
void Classic_SendSetBlock(int x, int y, int z, cc_bool place, BlockID block);
|
||||
void Classic_SendLogin(void);
|
||||
void CPE_SendPlayerClick(int button, cc_bool pressed, cc_uint8 targetId, struct RayTracer* t);
|
||||
void CPE_SendNotifyAction(int action, cc_uint32 value);
|
||||
void CPE_SendNotifyAction(int action, cc_uint16 value);
|
||||
void CPE_SendNotifyPositionAction(int action, int x, int y, int z);
|
||||
|
||||
/* Send a PluginMessage to the server; data must contain 64 bytes. */
|
||||
CC_API void CPE_SendPluginMessage(cc_uint8 channel, cc_uint8* data);
|
||||
|
|
Loading…
Reference in a new issue