mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-22 23:06:18 +00:00
Xuinia
This commit is contained in:
parent
5352c63336
commit
076ea10681
10 changed files with 36 additions and 147 deletions
|
|
@ -101,7 +101,6 @@ RB_METHOD(graphicsFrameReset){
|
||||||
return rb_bool_new(value); \
|
return rb_bool_new(value); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RB_METHOD(graphicsPosX){
|
RB_METHOD(graphicsPosX){
|
||||||
RB_UNUSED_PARAM;
|
RB_UNUSED_PARAM;
|
||||||
return INT2FIX(shState->graphics().x());
|
return INT2FIX(shState->graphics().x());
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,4 @@
|
||||||
#==============================================================================
|
|
||||||
# ** Main
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# After defining each class, actual processing begins here.
|
# After defining each class, actual processing begins here.
|
||||||
#==============================================================================
|
|
||||||
|
|
||||||
#at_exit do
|
|
||||||
# Wallpaper.reset
|
|
||||||
# save unless $game_switches[99] || ($game_system.map_interpreter.running? || !$scene.is_a?(Scene_Map))
|
|
||||||
#end
|
|
||||||
|
|
||||||
class Float
|
class Float
|
||||||
def to_f
|
def to_f
|
||||||
|
|
|
||||||
|
|
@ -1,113 +1,8 @@
|
||||||
N = 5_000_000
|
c = 0
|
||||||
sink = 0
|
while c < 1000
|
||||||
|
c = c + 1
|
||||||
# 1. Цикл, арифметика и ветвления
|
puts c
|
||||||
i = 0
|
Graphics.frame_reset
|
||||||
while i < N
|
Graphics.update
|
||||||
sink ^= (i * 31 + 17) % 1_000_003
|
Font.default_size = c
|
||||||
i += 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# 2. Вызовы методов
|
|
||||||
class TestObject
|
|
||||||
def initialize(value)
|
|
||||||
@value = value
|
|
||||||
end
|
|
||||||
|
|
||||||
def calculate(x)
|
|
||||||
((@value + x) * 3) ^ 0x55aa
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
objects = Array.new(10) { |x| TestObject.new(x) }
|
|
||||||
|
|
||||||
i = 0
|
|
||||||
while i < N
|
|
||||||
sink ^= objects[i % objects.length].calculate(i)
|
|
||||||
i += 1
|
|
||||||
end
|
|
||||||
|
|
||||||
# 3. Создание объектов и сборка мусора
|
|
||||||
i = 0
|
|
||||||
while i < N
|
|
||||||
data = {
|
|
||||||
id: i,
|
|
||||||
name: "object_#{i}",
|
|
||||||
values: [i, i * 2, i * 3],
|
|
||||||
enabled: (i & 1) == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
sink ^= data[:values][1]
|
|
||||||
i += 1
|
|
||||||
end
|
|
||||||
|
|
||||||
# 4. Строковые операции
|
|
||||||
text = "benchmark_string_" * 20
|
|
||||||
|
|
||||||
i = 0
|
|
||||||
while i < N
|
|
||||||
value = "#{text}:#{i}".upcase.reverse
|
|
||||||
sink ^= value.length
|
|
||||||
i += 1
|
|
||||||
end
|
|
||||||
|
|
||||||
# 5. Массивы
|
|
||||||
array = Array.new(10_000) { |x| x }
|
|
||||||
|
|
||||||
i = 0
|
|
||||||
while i < N
|
|
||||||
array[i % array.length] = (array[i % array.length] * 31 + i) % 1_000_003
|
|
||||||
sink ^= array[i % array.length]
|
|
||||||
i += 1
|
|
||||||
end
|
|
||||||
|
|
||||||
# 6. Hash lookup
|
|
||||||
hash = {}
|
|
||||||
10_000.times do |x|
|
|
||||||
hash["key_#{x}"] = x
|
|
||||||
end
|
|
||||||
|
|
||||||
i = 0
|
|
||||||
while i < N
|
|
||||||
sink ^= hash["key_#{i % 10_000}"]
|
|
||||||
i += 1
|
|
||||||
end
|
|
||||||
|
|
||||||
# 7. BigInt-арифметика
|
|
||||||
big = (1 << 100_000) + 12_345
|
|
||||||
|
|
||||||
200.times do
|
|
||||||
big = big * big
|
|
||||||
big %= (1 << 100_000) - 1
|
|
||||||
sink ^= big & 0xffff
|
|
||||||
end
|
|
||||||
|
|
||||||
# 8. Исключения
|
|
||||||
exception_count = 100_000
|
|
||||||
i = 0
|
|
||||||
|
|
||||||
while i < exception_count
|
|
||||||
begin
|
|
||||||
raise RuntimeError, "benchmark error"
|
|
||||||
rescue RuntimeError
|
|
||||||
sink += 1
|
|
||||||
end
|
|
||||||
|
|
||||||
i += 1
|
|
||||||
end
|
|
||||||
|
|
||||||
# 9. clone / dup
|
|
||||||
object = {
|
|
||||||
name: "test",
|
|
||||||
values: Array.new(100, 123),
|
|
||||||
nested: { enabled: true }
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0
|
|
||||||
while i < N
|
|
||||||
copy = object.dup
|
|
||||||
sink ^= copy[:values].length
|
|
||||||
i += 1
|
|
||||||
end
|
|
||||||
|
|
||||||
puts "sink=#{sink}"
|
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ void Config::read(int argc, char *argv[]){
|
||||||
PO_DESC(windowTitle, std::string, "") \
|
PO_DESC(windowTitle, std::string, "") \
|
||||||
PO_DESC(commonDataPath, std::string, "") \
|
PO_DESC(commonDataPath, std::string, "") \
|
||||||
PO_DESC(Modloader.ModsDirPath, std::string,"mods") \
|
PO_DESC(Modloader.ModsDirPath, std::string,"mods") \
|
||||||
|
PO_DESC(Modloader.skip_modloader_screen, bool, false) \
|
||||||
PO_DESC(fixedFramerate, int, 0) \
|
PO_DESC(fixedFramerate, int, 0) \
|
||||||
PO_DESC(frameSkip, bool, true) \
|
PO_DESC(frameSkip, bool, true) \
|
||||||
PO_DESC(syncToRefreshrate, bool, false) \
|
PO_DESC(syncToRefreshrate, bool, false) \
|
||||||
|
|
@ -91,7 +92,6 @@ void Config::read(int argc, char *argv[]){
|
||||||
PO_DESC(SE.sourceCount, int, 6) \
|
PO_DESC(SE.sourceCount, int, 6) \
|
||||||
PO_DESC(pathCache, bool, true) \
|
PO_DESC(pathCache, bool, true) \
|
||||||
PO_DESC(Windows_AllocConsole, bool, false) \
|
PO_DESC(Windows_AllocConsole, bool, false) \
|
||||||
PO_DESC(Modloader.use_default_save_path, bool, false) \
|
|
||||||
PO_DESC(pancakes, bool, false) \
|
PO_DESC(pancakes, bool, false) \
|
||||||
PO_DESC(SecurityEngine, bool, true) \
|
PO_DESC(SecurityEngine, bool, true) \
|
||||||
PO_DESC(journal_address, std::string, "127.0.0.1") \
|
PO_DESC(journal_address, std::string, "127.0.0.1") \
|
||||||
|
|
@ -170,3 +170,4 @@ void Config::read(int argc, char *argv[]){
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ struct Config{
|
||||||
|
|
||||||
struct{
|
struct{
|
||||||
std::string ModsDirPath;
|
std::string ModsDirPath;
|
||||||
bool use_default_save_path;
|
bool skip_modloader_screen;
|
||||||
} Modloader;
|
} Modloader;
|
||||||
|
|
||||||
bool useScriptNames;
|
bool useScriptNames;
|
||||||
|
|
|
||||||
|
|
@ -340,7 +340,7 @@ int main(int argc, char *argv[]){
|
||||||
|
|
||||||
unloadLocale();
|
unloadLocale();
|
||||||
unloadLanguageMetadata();
|
unloadLanguageMetadata();
|
||||||
if(show_crash_sceen){
|
if(show_crash_screen){
|
||||||
crash_screen(win);
|
crash_screen(win);
|
||||||
}
|
}
|
||||||
MIX_DestroyMixer(mixer);
|
MIX_DestroyMixer(mixer);
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ static void get_reason_and_solution(Exception::Type t) {
|
||||||
break;
|
break;
|
||||||
case Exception::NoFileError:
|
case Exception::NoFileError:
|
||||||
crash_reason = "Broken installation";
|
crash_reason = "Broken installation";
|
||||||
crash_possible_solution = "Try reinstall game";
|
crash_possible_solution = "Try reinstall game or mods if you load some mods.";
|
||||||
break;
|
break;
|
||||||
case Exception::ShaderError:
|
case Exception::ShaderError:
|
||||||
crash_reason = "Broken Shader";
|
crash_reason = "Broken Shader";
|
||||||
|
|
@ -186,7 +186,7 @@ void crash(Exception::Type t, const char *fmt, ...) {
|
||||||
SDL_vsnprintf(crash_message, sizeof(crash_message), fmt, args);
|
SDL_vsnprintf(crash_message, sizeof(crash_message), fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
get_reason_and_solution(t);
|
get_reason_and_solution(t);
|
||||||
show_crash_sceen = true;
|
show_crash_screen = true;
|
||||||
//Protect against segfaults
|
//Protect against segfaults
|
||||||
if(is_ruby_initialized){
|
if(is_ruby_initialized){
|
||||||
ruby_stop(-1);
|
ruby_stop(-1);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
inline std::vector<std::string> logs = {};
|
inline std::vector<std::string> logs = {};
|
||||||
inline std::vector<std::string> modloader_logs = {};
|
inline std::vector<std::string> modloader_logs = {};
|
||||||
|
|
||||||
inline bool show_crash_sceen = false;
|
inline bool show_crash_screen = false;
|
||||||
inline bool is_privacy_crashdump_enabled = false;
|
inline bool is_privacy_crashdump_enabled = false;
|
||||||
inline bool is_ruby_initialized = false;
|
inline bool is_ruby_initialized = false;
|
||||||
inline char crash_message[1024] = "";
|
inline char crash_message[1024] = "";
|
||||||
|
|
|
||||||
|
|
@ -68,25 +68,24 @@ static int renderer_thread(void* data){
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModLoader(Config conf, SDL_Window* win){
|
void ModLoader(Config conf, SDL_Window* win){
|
||||||
std::string path = "mods";
|
if (!fs::exists(conf.Modloader.ModsDirPath) || !fs::is_directory(conf.Modloader.ModsDirPath)) {
|
||||||
if (!fs::exists(path) || !fs::is_directory(path)) {
|
|
||||||
Debug() << "[MODLOADER] Mods directory not found, skip.";
|
Debug() << "[MODLOADER] Mods directory not found, skip.";
|
||||||
return;
|
return;
|
||||||
}else if (fs::is_empty(path)) {
|
}else if (fs::is_empty(conf.Modloader.ModsDirPath)) {
|
||||||
Debug() << "[MODLOADER] Mods directory empty, skip.";
|
Debug() << "[MODLOADER] Mods directory empty, skip.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(conf.SecurityEngine){
|
if(conf.SecurityEngine){
|
||||||
SecurityManagerInit();
|
SecurityManagerInit();
|
||||||
}
|
}
|
||||||
SDL_Thread* render_thread_pointer = SDL_CreateThread(renderer_thread, "ModRenderer", win);
|
SDL_Thread* render_thread_pointer = NULL;
|
||||||
if (!render_thread_pointer) {
|
if(!conf.Modloader.skip_modloader_screen){
|
||||||
//TODO: Error handling
|
render_thread_pointer = SDL_CreateThread(renderer_thread, "ModRenderer", win);
|
||||||
}
|
}
|
||||||
std::vector<std::string> mod_list = {};
|
std::vector<std::string> mod_list = {};
|
||||||
try {
|
try {
|
||||||
// 1.check if any zip(mod) file, 2. calculate sha256 hash of zip(mod) files 3.mount mod via PhysFS
|
// 1.check if any zip(mod) file, 2.mount mod via PhysFS
|
||||||
for (const auto &entry : fs::directory_iterator(path, fs::directory_options::skip_permission_denied)) {
|
for (const auto &entry : fs::directory_iterator(conf.Modloader.ModsDirPath, fs::directory_options::skip_permission_denied)) {
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
auto p = entry.path();
|
auto p = entry.path();
|
||||||
if (!fs::is_regular_file(p, ec) || ec) continue;
|
if (!fs::is_regular_file(p, ec) || ec) continue;
|
||||||
|
|
@ -107,7 +106,9 @@ void ModLoader(Config conf, SDL_Window* win){
|
||||||
}
|
}
|
||||||
sleep(1);
|
sleep(1);
|
||||||
stop_render = true;
|
stop_render = true;
|
||||||
|
if(!conf.Modloader.skip_modloader_screen){
|
||||||
SDL_WaitThread(render_thread_pointer, NULL);
|
SDL_WaitThread(render_thread_pointer, NULL);
|
||||||
|
}
|
||||||
modloader_is_enabled = true;
|
modloader_is_enabled = true;
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
crash(Exception::ModLoaderError, "Something is wrong, Exception: %s ", e.what());
|
crash(Exception::ModLoaderError, "Something is wrong, Exception: %s ", e.what());
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,7 @@ set(ARCH_COMMON "")
|
||||||
set(ARCH_RELEASE -momit-leaf-frame-pointer
|
set(ARCH_RELEASE -momit-leaf-frame-pointer
|
||||||
-mlow-precision-recip-sqrt
|
-mlow-precision-recip-sqrt
|
||||||
-mlow-precision-sqrt
|
-mlow-precision-sqrt
|
||||||
-mlow-precision-div)
|
-mlow-precision-div
|
||||||
set(ARCH_DEBUG -menable-sysreg-checking)
|
-mearly-ra=all)
|
||||||
|
set(ARCH_DEBUG -menable-sysreg-checking
|
||||||
|
-mpoke-function-name)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue