minor fixes & changes

This commit is contained in:
Beu 2021-12-24 16:29:39 +01:00
parent 73a0978161
commit acbc40f03c
2 changed files with 52 additions and 26 deletions

View File

@ -38,7 +38,7 @@ foreach (Event in RacePendingEvents) {
declare netwrite Net_PlayerPhysics for Event.Player = InitPlayerPhysicsVariable(); declare netwrite Net_PlayerPhysics for Event.Player = InitPlayerPhysicsVariable();
Net_PlayerPhysics = InitPlayerPhysicsVariable(); Net_PlayerPhysics = InitPlayerPhysicsVariable();
if (!ApplyPhysics_Queue.existskey(Event.Player.User.WebServicesUserId)) ApplyPhysics_Queue[Event.Player.User.WebServicesUserId] = []; if (!ApplyPhysics_Queue.existskey(Event.Player.User.WebServicesUserId)) ApplyPhysics_Queue[Event.Player.User.WebServicesUserId] = [];
ApplyPhysics_Queue[Event.Player.User.WebServicesUserId] = DiffPhysics(Event.Player, True); ApplyPhysics_Queue[Event.Player.User.WebServicesUserId] = GetDiffPhysics(Event.Player, True);
} }
} }
} }
@ -58,12 +58,23 @@ declare netwrite Integer Net_CoolDownForEffects for _Player = 0;
declare netwrite Integer Net_CoolDownBeforeReset for _Player = 0; declare netwrite Integer Net_CoolDownBeforeReset for _Player = 0;
if (_EventName == "Reset") { if (_EventName == "Reset") {
Net_CoolDownBeforeReset = 0; Net_CoolDownBeforeReset = 0;
if (_Player != Null && !SetPlayer_DelayedIsFull(_Player) && (_Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned || _Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawning)) {
declare netwrite Net_PlayerPhysics for _Player = InitPlayerPhysicsVariable();
Net_PlayerPhysics = InitPlayerPhysicsVariable();
}
} else { } else {
Net_CoolDownBeforeReset = Now + (S_CoolDownBeforeReset * 1000); Net_CoolDownBeforeReset = Now + (S_CoolDownBeforeReset * 1000);
Net_CoolDownForEffects = Now + (S_CoolDownForEffects * 1000); Net_CoolDownForEffects = Now + (S_CoolDownForEffects * 1000);
} }
*** ***
***PhysicsController_BeforeAddApplyPhysicsEffect***
***
ApplyPhysics_Queue[Player.User.WebServicesUserId].add(GetPhysics("Reset", "", Now + (S_CoolDownBeforeReset * 1000) - 50));
ApplyPhysics_Queue[Player.User.WebServicesUserId].add(GetPhysics("Reset", "", Now + (S_CoolDownBeforeReset * 1000) + 50));
ApplyPhysics_Queue[Player.User.WebServicesUserId].add(GetPhysics(EventName, Value, Now + 50));
***
***Match_InitMap*** ***Match_InitMap***
*** ***
declare Integer WaitNextUpdate = 0; declare Integer WaitNextUpdate = 0;
@ -511,9 +522,6 @@ Void SetHolidayShowdownControlML() {
if (Net_CoolDownForEffects < ArenaNow && Frame.Visible == True) { if (Net_CoolDownForEffects < ArenaNow && Frame.Visible == True) {
DevLog("[main] Hide Cooldown UI for " ^ InputPlayer.User.Name); DevLog("[main] Hide Cooldown UI for " ^ InputPlayer.User.Name);
Frame.Visible = False; Frame.Visible = False;
} else if (Net_CoolDownBeforeReset != 0 && !InputPlayerIsSpectator() && Net_CoolDownBeforeReset < ArenaNow) {
DevLog("[main] Send Reset for " ^ InputPlayer.User.Name);
SendCustomEvent("Request.PlayerPhysics.Reset", [Owner.User.Login, "1"]);
} else if (Net_CoolDownForEffects > ArenaNow) { } else if (Net_CoolDownForEffects > ArenaNow) {
declare CMlFrame Frame <=> (Page.GetFirstChild("frame-Warning") as CMlFrame); declare CMlFrame Frame <=> (Page.GetFirstChild("frame-Warning") as CMlFrame);
declare CMlLabel Label <=> (Page.GetFirstChild("label-warning") as CMlLabel); declare CMlLabel Label <=> (Page.GetFirstChild("label-warning") as CMlLabel);
@ -566,8 +574,7 @@ Void SetHolidayShowdownControlML() {
declare Text Target; declare Text Target;
Target = Owner.User.Login; Target = Owner.User.Login;
DevLog("[PendingEvents] Request of " ^ Effect ^ " to " ^ Target); DevLog("[PendingEvents] Request of " ^ Effect ^ " to " ^ Target);
if (GetValueOfAnEffect(Last_PlayerPhysics, Effect) == "1") SendCustomEvent("Request.PlayerPhysics." ^ Effect, [Target, "0"]); SendCustomEvent("Request.PlayerPhysics." ^ Effect, [Target, "1"]);
else SendCustomEvent("Request.PlayerPhysics." ^ Effect, [Target, "1"]);
} }
} else if (Event.ControlId == "Toggle_Bg_SettingButton") { } else if (Event.ControlId == "Toggle_Bg_SettingButton") {
DevLog("[PendingEvents] Toggle UI by " ^ Owner.User.Login); DevLog("[PendingEvents] Toggle UI by " ^ Owner.User.Login);

View File

@ -1,7 +1,7 @@
#Extends "Modes/TrackMania/TM_TimeAttack_Online.Script.txt" #Extends "Modes/TrackMania/TM_TimeAttack_Online.Script.txt"
#Setting S_AdminPlayers "" as "Comma separated admin to manage all players physics" #Setting S_AdminPlayers "" as "Comma separated admin to manage all players physics"
#Setting S_LinksSpectatorsToPlayers "" as "Comma separated Spectator login linked to a Player login with a colon" // Exemple : "Spectator1Login:Player1Login] =Spectator1Login:Player2Login] =Spectator2Login:any". To prevent all spectators to control all players] = just add a random key:value like "lock:lock" #Setting S_LinksSpectatorsToPlayers "" as "Comma separated Spectator login linked to a Player login with a colon" // Exemple : "Spectator1Login:Player1Login,Spectator1Login:Player2Login,Spectator2Login:any". To prevent all spectators to control all players, just add a random key:value like "lock:lock"
#Setting S_ForcePlayersToBeControledBySpectators False as "Force Players to be controlled by Spectators" #Setting S_ForcePlayersToBeControledBySpectators False as "Force Players to be controlled by Spectators"
#Setting S_AllowPlayersToBeControledBySpectators True as "Allow Players to be controlled by Spectators" #Setting S_AllowPlayersToBeControledBySpectators True as "Allow Players to be controlled by Spectators"
@ -109,24 +109,35 @@ foreach (Event in UIManager.PendingEvents) { // TODO: Add Secure token to admins
if (Target == "all") { if (Target == "all") {
AllPlayersPhysics = GetUpdatedPlayerPhysicsVariable(EventName, Value, AllPlayersPhysics); AllPlayersPhysics = GetUpdatedPlayerPhysicsVariable(EventName, Value, AllPlayersPhysics);
foreach (Player in AllPlayers) { foreach (Player in AllPlayers) {
if (!ApplyPhysics_Queue.existskey(Player.User.WebServicesUserId)) ApplyPhysics_Queue[Player.User.WebServicesUserId] = []; if (!ApplyPhysics_Queue.existskey(Player.User.WebServicesUserId) || EventName == "Reset") {
ApplyPhysics_Queue[Player.User.WebServicesUserId].add(K_NewPhysicsEffect { ApplyPhysics_Queue[Player.User.WebServicesUserId] = [];
Time = Now, } else {
Effect = EventName, foreach (Key => NewPhysicsEffects in ApplyPhysics_Queue[Player.User.WebServicesUserId]) {
Value = Value if (NewPhysicsEffects.Effect == EventName && NewPhysicsEffects.Value == Value && NewPhysicsEffects.Time == Now) {
}); ApplyPhysics_Queue[Player.User.WebServicesUserId].removekey(Key);
}
}
}
---PhysicsController_BeforeAddApplyPhysicsEffect---
ApplyPhysics_Queue[Player.User.WebServicesUserId].add(GetPhysics(EventName, Value, Now));
declare netwrite K_PlayerPhysics Net_PlayerPhysics for Player = InitPlayerPhysicsVariable(); declare netwrite K_PlayerPhysics Net_PlayerPhysics for Player = InitPlayerPhysicsVariable();
Net_PlayerPhysics = AllPlayersPhysics; Net_PlayerPhysics = AllPlayersPhysics;
} }
} else { } else {
declare CSmPlayer Player = GetPlayer(Target); declare CSmPlayer Player = GetPlayer(Target);
if (Player != Null && (Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned || Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawning)) { if (Player != Null && (Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned || Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawning)) {
if (!ApplyPhysics_Queue.existskey(Player.User.WebServicesUserId)) ApplyPhysics_Queue[Player.User.WebServicesUserId] = []; if (!ApplyPhysics_Queue.existskey(Player.User.WebServicesUserId) || EventName == "Reset") {
ApplyPhysics_Queue[Player.User.WebServicesUserId].add(K_NewPhysicsEffect { ApplyPhysics_Queue[Player.User.WebServicesUserId] = [];
Time = Now, } else {
Effect = EventName, declare Boolean AlreadyPassed;
Value = Value foreach (Key => NewPhysicsEffects in ApplyPhysics_Queue[Player.User.WebServicesUserId]) {
}); if (NewPhysicsEffects.Effect == EventName && NewPhysicsEffects.Value == Value && NewPhysicsEffects.Time == Now) {
ApplyPhysics_Queue[Player.User.WebServicesUserId].removekey(Key);
}
}
}
---PhysicsController_BeforeAddApplyPhysicsEffect---
ApplyPhysics_Queue[Player.User.WebServicesUserId].add(GetPhysics(EventName, Value, Now));
declare netwrite K_PlayerPhysics Net_PlayerPhysics for Player = InitPlayerPhysicsVariable(); declare netwrite K_PlayerPhysics Net_PlayerPhysics for Player = InitPlayerPhysicsVariable();
Net_PlayerPhysics = GetUpdatedPlayerPhysicsVariable(EventName, Value, Net_PlayerPhysics); Net_PlayerPhysics = GetUpdatedPlayerPhysicsVariable(EventName, Value, Net_PlayerPhysics);
} }
@ -147,7 +158,7 @@ foreach (Event in UIManager.PendingEvents) { // TODO: Add Secure token to admins
AllPlayersPhysics = InitPlayerPhysicsVariable(); AllPlayersPhysics = InitPlayerPhysicsVariable();
if (Locked) { if (Locked) {
foreach (Player in AllPlayers) { foreach (Player in AllPlayers) {
if (!ApplyPhysics_Queue.existskey(Player.User.WebServicesUserId)) ApplyPhysics_Queue[Player.User.WebServicesUserId] = []; ApplyPhysics_Queue[Player.User.WebServicesUserId] = [];
ApplyPhysics_Queue[Player.User.WebServicesUserId].add(K_NewPhysicsEffect { ApplyPhysics_Queue[Player.User.WebServicesUserId].add(K_NewPhysicsEffect {
Time = Now, Time = Now,
Effect = "Reset" Effect = "Reset"
@ -228,7 +239,8 @@ if (Net_ServerAllowPlayersToBeControledBySpectators != S_AllowPlayersToBeControl
foreach (AccountId => ArrayNewPlayerPhysics in ApplyPhysics_Queue) { foreach (AccountId => ArrayNewPlayerPhysics in ApplyPhysics_Queue) {
declare CSmPlayer Player = ModeUtils::GetPlayerFromAccountId(AccountId); declare CSmPlayer Player = ModeUtils::GetPlayerFromAccountId(AccountId);
foreach (Key => NewPlayerPhysics in ArrayNewPlayerPhysics) { foreach (Key => NewPlayerPhysics in ArrayNewPlayerPhysics) {
if (Player != Null && (Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned || Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawning)) { if (Player != Null && NewPlayerPhysics.Time <= Now && (Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned || Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawning)) {
Log::Log("[ApplyPhysics] Trying to set Event " ^ NewPlayerPhysics.Effect ^ " for " ^ Player.User.Name);
if (SetPlayerPhysics(NewPlayerPhysics.Effect,NewPlayerPhysics.Value,Player)) { if (SetPlayerPhysics(NewPlayerPhysics.Effect,NewPlayerPhysics.Value,Player)) {
ApplyPhysics_Queue[AccountId].removekey(Key); ApplyPhysics_Queue[AccountId].removekey(Key);
if (ApplyPhysics_Queue[AccountId].count == 0) ApplyPhysics_Queue.removekey(AccountId); if (ApplyPhysics_Queue[AccountId].count == 0) ApplyPhysics_Queue.removekey(AccountId);
@ -246,9 +258,8 @@ foreach (AccountId => ArrayNewPlayerPhysics in ApplyPhysics_Queue) {
foreach (Event in RacePendingEvents) { foreach (Event in RacePendingEvents) {
Log::Log("[RacePendingEvents] Event.Type: " ^ Event.Type); Log::Log("[RacePendingEvents] Event.Type: " ^ Event.Type);
if (Event.Type == Events::C_Type_StartLine || Event.Type == Events::C_Type_GiveUp || Event.Type == Events::C_Type_SkipOutro || Event.Type == Events::C_Type_Respawn) { if (Event.Type == Events::C_Type_StartLine || Event.Type == Events::C_Type_GiveUp || Event.Type == Events::C_Type_SkipOutro || Event.Type == Events::C_Type_Respawn) {
declare K_NewPhysicsEffect[] NewPhysics = DiffPhysics(Event.Player, (Event.Type == Events::C_Type_Respawn)); declare K_NewPhysicsEffect[] NewPhysics = GetDiffPhysics(Event.Player, (Event.Type == Events::C_Type_Respawn));
if (NewPhysics.count > 0) { if (NewPhysics.count > 0) {
if (!ApplyPhysics_Queue.existskey(Event.Player.User.WebServicesUserId)) ApplyPhysics_Queue[Event.Player.User.WebServicesUserId] = [];
ApplyPhysics_Queue[Event.Player.User.WebServicesUserId] = NewPhysics; ApplyPhysics_Queue[Event.Player.User.WebServicesUserId] = NewPhysics;
} }
} }
@ -269,7 +280,7 @@ K_PlayerPhysics InitPlayerPhysicsVariable() {
Boolean SetPlayerPhysics(Text _EventName, Text _EventValue, CSmPlayer _Player) { Boolean SetPlayerPhysics(Text _EventName, Text _EventValue, CSmPlayer _Player) {
Log::Log("[SetPhysicsChange] _EventName: " ^ _EventName ^" / _EventValue: "^ _EventValue ^ " / _Player: " ^ _Player.User.Name); Log::Log("[SetPhysicsChange] _EventName: " ^ _EventName ^" / _EventValue: "^ _EventValue ^ " / _Player: " ^ _Player.User.Name);
---PhysicsController_SetPhysicsChange--- ---PhysicsController_SetPhysicsChange---
if (_Player != Null && !SetPlayer_DelayedIsFull(_Player) && _Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned || _Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawning) { if (_Player != Null && !SetPlayer_DelayedIsFull(_Player) && (_Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned || _Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawning)) {
switch (_EventName) { switch (_EventName) {
case "AccelCoef": SetPlayer_Delayed_AccelCoef(_Player, TL::ToReal(_EventValue)); case "AccelCoef": SetPlayer_Delayed_AccelCoef(_Player, TL::ToReal(_EventValue));
case "AdherenceCoef": SetPlayer_Delayed_AdherenceCoef(_Player, TL::ToReal(_EventValue)); case "AdherenceCoef": SetPlayer_Delayed_AdherenceCoef(_Player, TL::ToReal(_EventValue));
@ -344,7 +355,15 @@ K_PlayerPhysics GetUpdatedPlayerPhysicsVariable(Text _EventName, Text _EventValu
return NewPlayerPhysics; return NewPlayerPhysics;
} }
K_NewPhysicsEffect[] DiffPhysics(CSmPlayer _Player, Boolean _Reset) { K_NewPhysicsEffect GetPhysics(Text _Effect, Text _Value, Integer _Time) {
return K_NewPhysicsEffect {
Time = _Time,
Effect = _Effect,
Value = _Value
};
}
K_NewPhysicsEffect[] GetDiffPhysics(CSmPlayer _Player, Boolean _Reset) {
declare K_PlayerPhysics DefaultPlayerPhysics = InitPlayerPhysicsVariable(); declare K_PlayerPhysics DefaultPlayerPhysics = InitPlayerPhysicsVariable();
declare netwrite K_PlayerPhysics Net_PlayerPhysics for _Player = InitPlayerPhysicsVariable(); declare netwrite K_PlayerPhysics Net_PlayerPhysics for _Player = InitPlayerPhysicsVariable();