Created
December 12, 2024 02:17
-
-
Save zebreus/b9cfa51c2523fdc7cbf17476f84afc4f to your computer and use it in GitHub Desktop.
openttd patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 6b06994c972693e0ebf1e402179724245dd94d06 Mon Sep 17 00:00:00 2001 | |
From: Zebreus <[email protected]> | |
Date: Thu, 12 Dec 2024 03:11:23 +0100 | |
Subject: [PATCH] Add serialcaixianlin support | |
--- | |
src/timer/timer_game_calendar.cpp | 25 +++++++++++++++++++++++++ | |
1 file changed, 25 insertions(+) | |
diff --git a/src/timer/timer_game_calendar.cpp b/src/timer/timer_game_calendar.cpp | |
index 30f938464c..d51f6a2ba3 100644 | |
--- a/src/timer/timer_game_calendar.cpp | |
+++ b/src/timer/timer_game_calendar.cpp | |
@@ -26,8 +26,17 @@ | |
#include "timer_game_calendar.h" | |
#include "../vehicle_base.h" | |
+#include <iostream> | |
+#include <fstream> | |
+#include <cstdlib> | |
+#include <thread> | |
+ | |
#include "../safeguards.h" | |
+#include "../company_func.h" | |
+#include "../company_base.h" | |
+#include "../company_gui.h" | |
+ | |
TimerGameCalendar::Year TimerGameCalendar::year = {}; | |
TimerGameCalendar::Month TimerGameCalendar::month = {}; | |
TimerGameCalendar::Date TimerGameCalendar::date = {}; | |
@@ -93,6 +102,20 @@ void TimeoutTimer<TimerGameCalendar>::Elapsed(TimerGameCalendar::TElapsed trigge | |
} | |
} | |
+static long long int last_money = 0; | |
+void performance_evaluation() { | |
+ const Company *c = Company::GetIfValid(_local_company); | |
+ auto money = c->money - c->current_loan; | |
+ bool lost_money = money < last_money; | |
+ last_money = money; | |
+ std::cout << "You " << c->money << (lost_money ? "lost money" : "gained_money") << std::endl; | |
+ if (lost_money) { | |
+ std::system("echo 'id 1337\nchannel 0\ns 1\nt 6\n' > /dev/ttyACM0"); | |
+ } else { | |
+ std::system("echo 'id 1337\nchannel 0\nv 50\nt 6\n' > /dev/ttyACM0"); | |
+ } | |
+} | |
+ | |
template<> | |
bool TimerManager<TimerGameCalendar>::Elapsed([[maybe_unused]] TimerGameCalendar::TElapsed delta) | |
{ | |
@@ -144,9 +167,11 @@ bool TimerManager<TimerGameCalendar>::Elapsed([[maybe_unused]] TimerGameCalendar | |
} | |
if (new_month) { | |
+ std::thread command_thread(performance_evaluation); | |
for (auto timer : timers) { | |
timer->Elapsed(TimerGameCalendar::MONTH); | |
} | |
+ command_thread.join(); | |
} | |
if (new_year) { | |
-- | |
2.47.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment