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

Huge lag during lasers. #24

Open
Boii1 opened this issue Jan 21, 2020 · 9 comments
Open

Huge lag during lasers. #24

Boii1 opened this issue Jan 21, 2020 · 9 comments
Assignees
Labels

Comments

@Boii1
Copy link

Boii1 commented Jan 21, 2020

Drops FPS by huge percentages when a laser is present on the screen. This is on 1.2.108 on TH10.

@Netdex Netdex added this to To do in VO Algorithm via automation Jan 21, 2020
@Netdex Netdex added the bug label Jan 21, 2020
@Netdex Netdex self-assigned this Jan 21, 2020
@Netdex
Copy link
Owner

Netdex commented Jan 21, 2020

Hi, thanks for reporting this issue.

The lag from lasers is because I used a generalized separating axis test for lasers, since they are modelled by an oriented bounding box (OBB). This implementation is optimized for complex polygons, which is overkill for this case since the hit test between the player and a laser is a simple AABB/OBB collision test. I'll probably replace it with a more efficient implementation.

@Boii1
Copy link
Author

Boii1 commented Jan 22, 2020

Makes sense. Another note, newer versions past 1.2.108 can't seem to boot TH10. Tried both patched and unpatched, even tried to manually build it and it could not open it.

@Netdex
Copy link
Owner

Netdex commented Jan 22, 2020

Hmmm... I'm assuming 1.2.112 didn't work either? I didn't change much between 1.2.108 and 1.2.112 except retargeting to v142. If you said you could manually build it then this probably isn't the problem.

One major change in 1.3 is that I rewrote the injector from scratch, which is likely to be the cause of the issue. The injector now needs a configuration file called twinject.toml instead of twinject.ini in the same directory as twinject.exe.

I don't think I updated the deploy script to add the TOML file to the release (or the documentation), so this is probably the problem. It's supposed to print an error when it can't find the file though, so it's weird that it failed silently.

@Boii1
Copy link
Author

Boii1 commented Jan 22, 2020

I had gone from the topmost updated version and worked my way down. I had tested each with the specified components on the page. 1.3 would inject HOWEVER TH10 would immediately crash because of the injection. 1.3.1 would not launch whatsoever. Then each below those until I got to 1.2.108 would launch and open the game only to immediately close.

@Netdex
Copy link
Owner

Netdex commented Jan 23, 2020

Interesting. Since the only thing that changed is the platform toolset and target version, my primary suspicion is that something to do with that broke MS Detours. The version included in this repo has been around since its conception, and doesn't actually support Windows 10 officially. Could you tell me the version of Windows you are using? I've verified that the injection works properly with version 1.3.1 on Windows 10 1809.

@Boii1
Copy link
Author

Boii1 commented Jan 26, 2020

I'm on Windows 10 Enterprise LTSC Version: 1809
Also sorry for late reply. I don't have notifications for GitHub enabled.

@Netdex
Copy link
Owner

Netdex commented Jan 28, 2020

No worries, this reply wasn't very quick either ¯_(ツ)_/¯
I also happen to be using Windows 10 Enterprise LTSC 1809, which rules that out as the cause. I'm currently working on a build with updated libraries and more detailed crash information which may help.

@Boii1
Copy link
Author

Boii1 commented Jan 29, 2020

Maybe catch any error that occurs before the program crashes and log it into a message box or text document?

Also just a suggestion but why not build an updater? I built a way to update files by URL like this:

// I'm just pulling all the includes I used for this program but I'm sure you could sort through them if you wanted to.

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
#include <array>
#include <Windows.h>
#include <vector>
#include <Urlmon.h>
#include <stdio.h>
#include <tchar.h>
#include <wininet.h>
#include <TlHelp32.h>
#pragma comment(lib, "urlmon.lib")

wstring S2WS(const string& str) {
	int length;
	int slength = (int)str.length() + 1;
	length = MultiByteToWideChar(CP_ACP, 0, str.c_str(), slength, 0, 0);
	wchar_t* buffer = new wchar_t[length];
	MultiByteToWideChar(CP_ACP, 0, str.c_str(), slength, buffer, length);
	wstring out(buffer);
	delete[] buffer;
	return out;
}

// File Downloader
int download(string url) {
	wstring wUrl = S2WS(url);
	LPCWSTR lUrl = wUrl.c_str();
	TCHAR path[MAX_PATH];
	GetCurrentDirectory(MAX_PATH, path);
	wcscat_s(path, L"\\dl.txt");
	HRESULT response = URLDownloadToFile(NULL, lUrl, path, 0, NULL);
	return 0;
}

I had this string->wstring converter since I was getting errors otherwise and URLDownloadToFile required a certain set of types making it obnoxious to use but this was as much as I had gotten. You can use it like such: download("https://www.w3.org/TR/PNG/iso_8859-1.txt");

All you'd need to do really is just change the download format to the zip file (for someone to extract or maybe find someplace it can be directly accessed unzipped?). The URL just needs to be a direct link to a file source. This allows it to work properly. Sending it to a site will attempt to download the current page if the page is served directly, meaning it can't be something like a site that hosts a download on a page and sends the file via request.

Also this took me around an hour to get properly working. It was a pain in the ass.

@Netdex
Copy link
Owner

Netdex commented Jan 31, 2020

Cool idea, thanks for taking the time to write up that concept code. I'll probably consider adding an updater, since it seems like a neat idea (after sorting out the crashes, of course). I've been quite busy irl lately so I've put this project on the backburner, but I'm always willing to review pull requests or answer questions about the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
VO Algorithm
  
To do
Development

No branches or pull requests

2 participants