mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-19 12:35:52 -04:00
Add +/-push to disallow player pushing in MOTD.
This commit is contained in:
parent
6113c4c270
commit
92664c258a
@ -35,7 +35,7 @@ namespace ClassicalSharp.Audio {
|
||||
if (volume != 0) return volume;
|
||||
|
||||
volume = Options.GetBool(boolKey, false) ? 100 : 0;
|
||||
Options.Set<string>(boolKey, null);
|
||||
Options.Set(boolKey, null);
|
||||
return volume;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,8 @@ namespace ClassicalSharp.Entities {
|
||||
public bool CanSeeAllNames = true;
|
||||
/// <summary> Whether the player is allowed to double jump. </summary>
|
||||
public bool CanDoubleJump = true;
|
||||
/// <summary> Whether the player can be pushed by other players. </summary>
|
||||
public bool CanBePushed = true;
|
||||
/// <summary> Maximum speed the entity can move at horizontally when CanSpeed is false. </summary>
|
||||
public float MaxSpeedMultiplier = 1;
|
||||
/// <summary> Amount of jumps the player can perform. </summary>
|
||||
@ -160,6 +162,8 @@ namespace ClassicalSharp.Entities {
|
||||
|
||||
MaxSpeedMultiplier = 1;
|
||||
MaxJumps = 1;
|
||||
CanBePushed = true;
|
||||
|
||||
// By default (this is also the case with WoM), we can use hacks.
|
||||
if (HacksFlags.Contains("-hax")) SetAllHacks(false);
|
||||
|
||||
@ -167,6 +171,7 @@ namespace ClassicalSharp.Entities {
|
||||
ParseFlag(ref CanNoclip, "noclip");
|
||||
ParseFlag(ref CanSpeed, "speed");
|
||||
ParseFlag(ref CanRespawn, "respawn");
|
||||
ParseFlag(ref CanBePushed, "push");
|
||||
|
||||
if (UserType == 0x64) ParseAllFlag("ophax");
|
||||
ParseHorizontalSpeed();
|
||||
|
@ -59,7 +59,7 @@ namespace ClassicalSharp.Entities {
|
||||
bool wasOnGround = onGround;
|
||||
|
||||
HandleInput(ref xMoving, ref zMoving);
|
||||
if (!Hacks.Noclip) physics.DoEntityPush();
|
||||
if (!Hacks.Noclip && Hacks.CanBePushed) physics.DoEntityPush();
|
||||
|
||||
// Immediate stop in noclip mode
|
||||
if (!Hacks.NoclipSlide && (Hacks.Noclip && xMoving == 0 && zMoving == 0))
|
||||
|
@ -74,7 +74,7 @@ namespace ClassicalSharp {
|
||||
public void SetViewDistance(float distance, bool userDist) {
|
||||
if (userDist) {
|
||||
UserViewDistance = distance;
|
||||
Options.Set(OptionsKey.ViewDist, distance);
|
||||
Options.Set(OptionsKey.ViewDist, (int)distance);
|
||||
}
|
||||
|
||||
distance = Math.Min(distance, MaxViewDistance);
|
||||
|
@ -68,7 +68,7 @@ namespace ClassicalSharp {
|
||||
void SaveKeyBindings() {
|
||||
string[] names = KeyBind.GetNames(typeof(KeyBind));
|
||||
for (int i = 0; i < names.Length; i++) {
|
||||
Options.Set("key-" + names[i], keys[i]);
|
||||
Options.Set("key-" + names[i], keys[i].ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,14 +129,13 @@ namespace ClassicalSharp {
|
||||
|
||||
public static T GetEnum<T>(string key, T defValue) {
|
||||
string value = Get(key);
|
||||
if (value == null) {
|
||||
Set(key, defValue);
|
||||
return defValue;
|
||||
}
|
||||
if (value == null) return defValue;
|
||||
|
||||
T mapping;
|
||||
if (!Utils.TryParseEnum(value, defValue, out mapping))
|
||||
Set(key, defValue);
|
||||
if (!Utils.TryParseEnum(value, defValue, out mapping)) {
|
||||
Set(key, defValue.ToString());
|
||||
mapping = defValue;
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
#endif
|
||||
@ -148,12 +147,14 @@ namespace ClassicalSharp {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void Set<T>(string key, T value) {
|
||||
public static void Set(string key, int value) { Set(key, value.ToString()); }
|
||||
public static void Set(string key, bool value) { Set(key, value.ToString()); }
|
||||
public static void Set(string key, string value) {
|
||||
if (value == null) {
|
||||
int i = FindOption(key);
|
||||
if (i >= 0) RemoveOption(i);
|
||||
} else {
|
||||
SetOption(key, value.ToString());
|
||||
SetOption(key, value);
|
||||
}
|
||||
|
||||
if (!OptionsChanged.Contains(key)) {
|
||||
|
@ -97,7 +97,7 @@ void Entity_ParseScale(Entity* entity, String scale) {
|
||||
entity->ModelScale = Vector3_Create1(value);
|
||||
}
|
||||
|
||||
void Entity_SetModel(Entity* entity, String* model) {
|
||||
void Entity_SetModel(Entity* entity, STRING_TRANSIENT String* model) {
|
||||
entity->ModelScale = Vector3_Create1(1.0f);
|
||||
entity->ModelBlock = BlockID_Air;
|
||||
String_Clear(&entity->ModelName);
|
||||
@ -335,6 +335,7 @@ void HacksComp_Init(HacksComp* hacks) {
|
||||
hacks->MaxSpeedMultiplier = 1.0f;
|
||||
hacks->MaxJumps = 1;
|
||||
hacks->NoclipSlide = true;
|
||||
hacks->CanBePushed = true;
|
||||
hacks->HacksFlags = String_FromRawBuffer(&hacks->HacksFlagsBuffer[0], 128);
|
||||
}
|
||||
|
||||
@ -447,6 +448,8 @@ void HacksComp_UpdateState(HacksComp* hacks) {
|
||||
|
||||
hacks->MaxSpeedMultiplier = 1;
|
||||
hacks->MaxJumps = 1;
|
||||
hacks->CanBePushed = true;
|
||||
|
||||
/* By default (this is also the case with WoM), we can use hacks. */
|
||||
String excHacks = String_FromConstant("-hax");
|
||||
if (String_ContainsString(&hacks->HacksFlags, &excHacks)) {
|
||||
@ -457,6 +460,7 @@ void HacksComp_UpdateState(HacksComp* hacks) {
|
||||
HacksComp_ParseFlag(hacks, "+noclip", "-noclip", &hacks->CanNoclip);
|
||||
HacksComp_ParseFlag(hacks, "+speed", "-speed", &hacks->CanSpeed);
|
||||
HacksComp_ParseFlag(hacks, "+respawn", "-respawn", &hacks->CanRespawn);
|
||||
HacksComp_ParseFlag(hacks, "+push", "-push", &hacks->CanBePushed);
|
||||
|
||||
if (hacks->UserType == 0x64) {
|
||||
HacksComp_ParseAllFlag(hacks, "+ophax", "-ophax");
|
||||
|
@ -125,7 +125,7 @@ void Entity_GetPickingBounds(Entity* entity, AABB* bb);
|
||||
/* Bounding box of the model that collision detection is performed with, in world coordinates. */
|
||||
void Entity_GetBounds(Entity* entity, AABB* bb);
|
||||
/* Sets the model associated with this entity. ('name' or 'name|scale') */
|
||||
void Entity_SetModel(Entity* entity, String* model);
|
||||
void Entity_SetModel(Entity* entity, STRING_TRANSIENT String* model);
|
||||
void Entity_UpdateModelBounds(Entity* entity);
|
||||
/* Determines whether any of the blocks that intersect the given bounding box satisfy the given condition. */
|
||||
bool Entity_TouchesAny(AABB* bb, TouchesAny_Condition condition);
|
||||
@ -182,6 +182,8 @@ typedef struct HacksComponent_ {
|
||||
bool CanSeeAllNames;
|
||||
/* Whether the player is allowed to double jump. */
|
||||
bool CanDoubleJump;
|
||||
/* Whether the player can be pushed by other players. */
|
||||
bool CanBePushed;
|
||||
/* Maximum speed the entity can move at horizontally when CanSpeed is false. */
|
||||
Real32 MaxSpeedMultiplier;
|
||||
/* Max amount of jumps the player can perform. */
|
||||
|
@ -121,7 +121,7 @@ void Options_SetInt32(const UInt8* keyRaw, Int32 value) {
|
||||
Options_Set(keyRaw, numStr);
|
||||
}
|
||||
|
||||
void Options_Set(const UInt8* keyRaw, String value) {
|
||||
void Options_Set(const UInt8* keyRaw, STRING_TRANSIENT String value) {
|
||||
String key = String_FromReadonly(keyRaw);
|
||||
Int32 i;
|
||||
if (value.buffer == NULL) {
|
||||
|
@ -86,5 +86,5 @@ bool Options_GetBool(const UInt8* key, bool defValue);
|
||||
Real32 Options_GetFloat(const UInt8* key, Real32 min, Real32 max, Real32 defValue);
|
||||
|
||||
void Options_SetInt32(const UInt8* keyRaw, Int32 value);
|
||||
void Options_Set(const UInt8* keyRaw, String value);
|
||||
void Options_Set(const UInt8* keyRaw, STRING_TRANSIENT String value);
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user