Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Engine update #26

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Configs/Debugging.focfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ RenderDebug = True
InactivityDisconnectTime = 0
MusicVolume = 0
SoundVolume = 0
DebuggingDeltaTimeCap = 100
ArtificalLags = 80
3 changes: 3 additions & 0 deletions Configs/Default.focfg
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,6 @@ DefaultSplashPack = FOnline
WindowCentered = True
WindowResizable = False
CollapseLogOnStart = False
ShowGroups = True
DebuggingDeltaTimeCap = 0
ArtificalLags = 0
2 changes: 1 addition & 1 deletion Engine
Submodule Engine updated 162 files
1 change: 1 addition & 0 deletions FormatSource.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
clang-format --verbose -i Scripts/*.fos Scripts/Json/*.fos Scripts/Extension/*.cpp
7 changes: 1 addition & 6 deletions Scripts/ClientMain.fos
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ void ModuleInit()
// Call on client loaded or new client_main.fos script received.
void start()
{
if (Settings.ScreenWidth < 800 || Settings.ScreenWidth > 1280 || Settings.ScreenHeight < 600 || Settings.ScreenHeight > 1024) {
// Recomendation message
Game.Message(Game.GetMsgStr(TEXTMSG_GAME, MsgStr::StrInvalidResolution));
}

Game.LoadFont(Fonts::Big, "*Big");
Game.LoadFont(Fonts::BigNum, "*BigNumbers");
Game.LoadFont(Fonts::Default, "*Default");
Expand Down Expand Up @@ -291,7 +286,7 @@ bool map_message(string& message, uint16& hexX, uint16& hexY, uint& color, uint&
// //////////////////////////////////////////////////////////////////////////////////////////////////
// Call on receive message.
// By default delay == [TextDelay + message length * 100] ms
bool in_message(string message, int& sayType, uint& critterId, uint& delay)
bool in_message(string message, int& sayType, ident_t critterId, uint& delay)
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Combat.fos
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void AddEff(Critter crit, uint[] eff, CombatRes[] combatResults)
}

while (combatResults[ptr].Crit.Id != crit.Id) {
if (crit.Id < combatResults[ptr].Crit.Id) {
if (int64(crit.Id) < int64(combatResults[ptr].Crit.Id)) {
if (combatResults[ptr].Left != PTR_NULL) {
ptr = combatResults[ptr].Left;
}
Expand Down
6 changes: 3 additions & 3 deletions Scripts/Drugs.fos
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ void SetDrug(Critter cr, hstring drugPid)
}
else if (drugPid == Content::Item::jet_antidote) {
uint[] indexes = {};
uint[] durations = {};
tick_t[] durations = {};
uint[] rates = {};
uint count = cr.GetTimeEvents(Content::Item::jet.hash, indexes, durations, rates);
for (uint i = 0; i < count; i++) {
Expand Down Expand Up @@ -313,7 +313,7 @@ void SetDrug(Critter cr, hstring drugPid)

// Other drugs
uint[] indexes = {};
uint[] durations = {};
tick_t[] durations = {};
uint[] rates = {};
uint count = cr.GetTimeEvents(drugPid.hash, indexes, durations, rates);
int index = GetDrugTableIndex(drugPid);
Expand Down Expand Up @@ -496,7 +496,7 @@ uint ProcessDrug(Critter cr, hstring drugPid, uint rate)
{
// Find already processed addiction
uint[] indexes = {};
uint[] durations = {};
tick_t[] durations = {};
uint[] rates = {};
uint count = cr.GetTimeEvents(drugPid.hash, indexes, durations, rates);
bool isPresent = false;
Expand Down
6 changes: 3 additions & 3 deletions Scripts/EnergyBarier.fos
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,10 @@ class CBarier
}
else {
if (mode == BM_HALF_ON) {
Blockers[i].OnWalk.Subscribe(_DamageCritter);
Blockers[i].OnCritterWalk.Subscribe(_DamageCritter);
}
else {
Blockers[i].OnWalk.Unsubscribe(_DamageCritter);
Blockers[i].OnCritterWalk.Unsubscribe(_DamageCritter);
}

if (HaveHalfOnMode == hstring() && mode == BM_HALF_ON) {
Expand Down Expand Up @@ -578,7 +578,7 @@ void InitTriggers(CBarier barier)
{
DL("Инициализация триггеров. Количество: " + barier.Triggers.length());
for (uint i = 0; i < barier.Triggers.length(); i++) {
barier.Triggers[i].OnWalk.Subscribe(_WalkOnTrigg);
barier.Triggers[i].OnCritterWalk.Subscribe(_WalkOnTrigg);
barier.Triggers[i].Val1 = barier.GetGuardNum();
barier.Triggers[i].Val2 = barier.Barier.Id;
barier.Triggers[i].Val3 = barier.Barier.Val1;
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Explode.fos
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void _ExplodeInit(Item item, bool firstTime)
{
if (item.ProtoId == Content::Item::active_mine) {
item.IsTrap = true;
item.OnWalk.Subscribe(_MineWalk);
item.OnCritterWalk.Subscribe(_MineWalk);
}
}

Expand Down Expand Up @@ -276,7 +276,7 @@ void ExplodeEx(Map map, uint16 hexX, uint16 hexY, hstring effectPid, uint effect
void _TimerMineInit(Item mine, bool firstTime)
{
if (mine.ProtoId == Content::Item::active_mine) {
mine.OnWalk.Subscribe(_TimerMineWalk);
mine.OnCritterWalk.Subscribe(_TimerMineWalk);
mine.OnCritterUseSkill.Subscribe(_OnSkillTimerMine);
mine.ExplodeBonusRadius = CLAMP(mine.ExplodeBonusRadius, 1, 5);
mine.IsTrap = true;
Expand Down
8 changes: 4 additions & 4 deletions Scripts/GameTime.fos
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
uint16 GetHour()
{
uint16 year = 0, month = 0, day = 0, dayOfWeek = 0, hour = 0, minute = 0, second = 0;
Game.GetGameTime(Game.GetFullSecond(), year, month, day, dayOfWeek, hour, minute, second);
Game.EvaluateGameTime(Game.GetFullSecond(), year, month, day, dayOfWeek, hour, minute, second);
return hour;
}

uint16 GetMinute()
{
uint16 year = 0, month = 0, day = 0, dayOfWeek = 0, hour = 0, minute = 0, second = 0;
Game.GetGameTime(Game.GetFullSecond(), year, month, day, dayOfWeek, hour, minute, second);
Game.EvaluateGameTime(Game.GetFullSecond(), year, month, day, dayOfWeek, hour, minute, second);
return minute;
}

uint16 GetMonth()
{
uint16 year = 0, month = 0, day = 0, dayOfWeek = 0, hour = 0, minute = 0, second = 0;
Game.GetGameTime(Game.GetFullSecond(), year, month, day, dayOfWeek, hour, minute, second);
Game.EvaluateGameTime(Game.GetFullSecond(), year, month, day, dayOfWeek, hour, minute, second);
return month;
}

uint16 GetYear()
{
uint16 year = 0, month = 0, day = 0, dayOfWeek = 0, hour = 0, minute = 0, second = 0;
Game.GetGameTime(Game.GetFullSecond(), year, month, day, dayOfWeek, hour, minute, second);
Game.EvaluateGameTime(Game.GetFullSecond(), year, month, day, dayOfWeek, hour, minute, second);
return year;
}
2 changes: 1 addition & 1 deletion Scripts/GlobalMapLocations.fos
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void OnPlayerSetKnownLocations(Critter cr)
}
}

void OnPlayerLogin(uint ip, string name, uint id, uint& textMsg, uint& strNum, string& lexems)
void OnPlayerLogin(uint ip, string name, ident_t id, uint& textMsg, uint& strNum, string& lexems)
{
uint[] values = {id, GM_INFO_ALL};
Game.DeferredCall(0, DeferredSendGlobalMapData, values);
Expand Down
14 changes: 2 additions & 12 deletions Scripts/InputHandler.fos
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ bool HandleHotkeys(KeyCode key)
break;

case KeyCode::F6:
Settings.ShowPlayerNames = !Settings.ShowPlayerNames;
Settings.ShowPlayerName = !Settings.ShowPlayerName;
break;
case KeyCode::F7:
if (Settings.DebugInfo) {
Settings.ShowNpcNames = !Settings.ShowNpcNames;
Settings.ShowNpcName = !Settings.ShowNpcName;
}
break;

Expand Down Expand Up @@ -288,16 +288,6 @@ bool HandleHotkeys(KeyCode key)
}
else {
switch (key) {
case KeyCode::F6:
if (Settings.DebugInfo && Input::IsCtrlDown()) {
Settings.ShowCritId = !Settings.ShowCritId;
}
break;
case KeyCode::F7:
if (Settings.DebugInfo && Input::IsCtrlDown()) {
Settings.ShowCritId = !Settings.ShowCritId;
}
break;
case KeyCode::F10:
if (Input::IsShiftDown()) {
Game.CustomCall("DumpAtlases");
Expand Down
19 changes: 17 additions & 2 deletions Scripts/Main.fos
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ void ModuleInit()
Game.OnMapLoopEx.Subscribe(map_loop_ex);
Game.OnPlayerCheckMove.Subscribe(OnPlayerCheckMove);
Game.OnPlayerCheckDir.Subscribe(OnPlayerCheckDir);
Game.OnCritterTalk.Subscribe(OnCritterTalk);
Game.OnCritterBarter.Subscribe(OnCritterBarter);
}

// Called on map loop
Expand Down Expand Up @@ -1218,6 +1220,8 @@ void critter_respawn(Critter cr)
// Call on something critter in to map.
void map_critter_in(Map map, Critter cr)
{
map.OnCritterIn.Fire(cr);

cr.TimeoutTransfer = TRANSFER_TIMEOUT(cr);

NoPvpMaps::OnCitterMapIn(cr, map);
Expand All @@ -1230,6 +1234,8 @@ void map_critter_in(Map map, Critter cr)
// Call on something critter out from map.
void map_critter_out(Map map, Critter cr)
{
map.OnCritterOut.Fire(cr);

cr.TimeoutBattle = 0;

NoPvpMaps::OnCritterMapOut(cr, map);
Expand Down Expand Up @@ -1306,7 +1312,7 @@ bool player_registration(uint ip, string name, uint& textMsg, uint& strNum, stri

// Call on player try login
// Return true to allow, false to disallow
bool player_login(uint ip, string name, uint id, uint& textMsg, uint& strNum, string& lexems)
bool player_login(uint ip, string name, ident_t id, uint& textMsg, uint& strNum, string& lexems)
{
if (Settings.PermanentDeath > 0 && Replication::IsPermanentDeath(id)) {
textMsg = TEXTMSG_GAME;
Expand Down Expand Up @@ -1351,7 +1357,6 @@ bool player_allowcommand(Player player, string adminPanel, uint8 command)
case COMMAND_ADDITEM_SELF:
case COMMAND_ADDLOCATION:
case COMMAND_ADDNPC:
case COMMAND_BAN:
case COMMAND_CHECKVAR:
case COMMAND_CRITID:
case COMMAND_DISCONCRIT:
Expand Down Expand Up @@ -1448,3 +1453,13 @@ bool OnPlayerCheckDir(Player player, Critter cr, int16& dirAngle)

return true;
}

void OnCritterTalk(Critter cr, Critter trader, bool begin, uint talkers)
{
cr.IsHide = false;
}

void OnCritterBarter(Critter cr, Critter trader, bool begin, uint barterCount)
{
cr.IsHide = false;
}
2 changes: 1 addition & 1 deletion Scripts/MapNcrBazaar.fos
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void _MapInit(Map bazaar, bool firstTime)
values.insertLast(loc.Id);
Game.DeferredCall(GAME_SECOND_TO_TICK(Time::GetNearFullSecond(0, 0, 0, 6, 0, 0) - Game.GetFullSecond()), RepeatDisableForceField, values);
Game.DeferredCall(GAME_SECOND_TO_TICK(Time::GetNearFullSecond(0, 0, 0, 20, 0, 0) - Game.GetFullSecond()), RepeatEnableForceField, values);
Game.GetGameTime(Game.GetFullSecond(), year, month, day, dayOfWeek, hour, minute, second);
Game.EvaluateGameTime(Game.GetFullSecond(), year, month, day, dayOfWeek, hour, minute, second);
if (hour >= 20 || hour < 5) {
Game.DeferredCall(0, EnergyBarier::EnableForceField, values);
}
Expand Down
2 changes: 1 addition & 1 deletion Scripts/MapNcrDowntown.fos
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void _MapInit(Map downtown, bool firstTime)
values.insertLast(loc.Id);
Game.DeferredCall(GAME_SECOND_TO_TICK(Time::GetNearFullSecond(0, 0, 0, 6, 0, 0) - Game.GetFullSecond()), RepeatableDisableForceField, values);
Game.DeferredCall(GAME_SECOND_TO_TICK(Time::GetNearFullSecond(0, 0, 0, 20, 0, 0) - Game.GetFullSecond()), RepeatableEnableForceField, values);
Game.GetGameTime(Game.GetFullSecond(), year, month, day, dayOfWeek, hour, minute, second);
Game.EvaluateGameTime(Game.GetFullSecond(), year, month, day, dayOfWeek, hour, minute, second);
if (hour >= 20 || hour < 5) {
Game.DeferredCall(0, EnergyBarier::EnableForceField, values);
}
Expand Down
2 changes: 1 addition & 1 deletion Scripts/NpcPlanes.fos
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ uint ProcessAi(Critter npc)

MovingState state = npc.GetMovingState();
if (state != MovingState::InProgress && state != MovingState::Success) {
uint gagId = 0;
ident_t gagId = 0;
npc.ResetMovingState(gagId);
int reason = REASON_TRACE_FAIL;
switch (state) {
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Poison.fos
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void AffectPoison(Critter cr, int value)
}

uint[] indexes = {};
uint[] durations = {};
tick_t[] durations = {};
uint[] rates = {};
bool isActive = cr.GetTimeEvents(Tla::CtePoison, indexes, durations, rates) != 0;
int levelVal = cr.PoisoningLevel;
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Radiation.fos
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void AffectRadiation(Critter cr, int value)
}

uint[] indexes = {};
uint[] durations = {};
tick_t[] durations = {};
uint[] rates = {};
bool isActive = cr.GetTimeEvents(Tla::CteRadiation, indexes, durations, rates) != 0;
int levelVal = cr.RadiationLevel;
Expand Down
2 changes: 1 addition & 1 deletion Scripts/ReddGates.fos
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ GatesControl FindGatesControl(Map map, int number) // Попытка найти
void _GatesInit(Item gates, bool firstTime)
{
gates.OnCritterUseSkill.Subscribe(_GatesSkill);
gates.OnWalk.Subscribe(_GatesWalk);
gates.OnCritterWalk.Subscribe(_GatesWalk);
}

bool _GatesSkill(Item gates, Critter player, CritterProperty skill) // Попытка открыть или взломать дверь. Запрещено открывать дверь, этим занимается охрана
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Repairer.fos
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ void dlg_GetRepairTime(Critter player, Critter npc, string& lexems)
uint16 hour = 0;
uint16 minute = 0;
uint16 second = 0;
Game.GetGameTime(player.RepairCompleteTime[npc.Id], year, month, dayOfWeek, day, hour, minute, second);
Game.EvaluateGameTime(player.RepairCompleteTime[npc.Id], year, month, dayOfWeek, day, hour, minute, second);
lexems = "$time" + (month > 9 ? ("" + month) : ("0" + month)) + "." + year + " " + (hour > 9 ? ("" + hour) : ("0" + hour)) + ":" +
(minute > 9 ? ("" + minute) : ("0" + minute));
}
Expand Down
2 changes: 1 addition & 1 deletion Scripts/SeForvrV13.fos
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

void _TranInit(Item item, bool firstTime)
{
item.OnWalk.Subscribe(_Transit);
item.OnCritterWalk.Subscribe(_Transit);
}

void t_Zizz(Critter cr, StaticItem trigger, bool entered, uint8 dir)
Expand Down
2 changes: 1 addition & 1 deletion Scripts/SmokeGrenade.fos
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void _SmokeInit(Item item, bool firstTime)
item.IsNoBlock = true;
item.IsShootThru = true;
if (item.ProtoId == Content::Item::mustard_gas) {
item.OnWalk.Subscribe(_MustardGasWalk);
item.OnCritterWalk.Subscribe(_MustardGasWalk);
}
// item.OnFinish.Subscribe(_SmokeFinish);
}
Expand Down
4 changes: 4 additions & 0 deletions Scripts/Tla.fos
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
///@ Setting Client int GmapGroupToX // координаты точки назначения
///@ Setting Client int GmapGroupToY
///@ Setting Client float GmapGroupSpeed // текущая скорость передвижения
///@ Setting Client bool ShowGroups

///@ Event Server Map OnCritterIn(Critter cr)
///@ Event Server Map OnCritterOut(Critter cr)

///@ Property Critter Public uint TimeoutBattle Temporary
///@ Property Critter Protected uint TimeoutTransfer Temporary
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Traveller.fos
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class Traveller
}

uint[] indexes = {};
uint[] durations = {};
tick_t[] durations = {};
uint[] rates = {};
if (cr.GetTimeEvents(CTE_CHECK, indexes, durations, rates) == 0) {
cr.AddTimeEvent(cte_Check, TIME_CHECK, CTE_CHECK);
Expand Down Expand Up @@ -463,7 +463,7 @@ bool _GlobalProcess(Critter cr, int type, Item car, float x, float y, float toX,

// Сброс проверок на застревание при достижении точки назначения
uint[] indexes = {};
uint[] durations = {};
tick_t[] durations = {};
uint[] rates = {};
if (cr.GetTimeEvents(CTE_CHECK, indexes, durations, rates) != 0) {
cr.EraseTimeEvents(CTE_CHECK);
Expand Down
2 changes: 1 addition & 1 deletion TLA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
SetupGame( DEV_NAME "TLA"
NICE_NAME "FOnlineTLA"
AUTHOR_NAME "FODev"
GAME_VERSION "0.1.0"
GAME_VERSION "0.1.1"
SINGLEPLAYER NO
ENABLE_3D NO
ANGELSCRIPT_SCRIPTING YES
Expand Down