Repository navigation
Expand file tree
/
Copy pathffrunner.h
More file actions
164 lines (140 loc) · 4.07 KB
/
Copy pathffrunner.h
File metadata and controls
164 lines (140 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#include <windows.h>
#include <wininet.h>
#include <shellscalingapi.h>
#include <dxgi.h>
#include "npapi/npapi.h"
#include "npapi/npfunctions.h"
#include "npapi/npruntime.h"
#include "npapi/nptypes.h"
#define LOG_FILE_PATH "ffrunner.log"
#define USERAGENT "ffrunner"
#define EXIT_PLUGIN_ERROR 2
#define CLASS_NAME L"FFWINDOW"
#define IO_MSG_NAME L"FFRunnerIoReady"
#define IO_MSG_PROGRESS 0
#define IO_MSG_FINAL 1
#define IO_MSG_RELEASE 2
#define REQUEST_CHUNK_SIZE 0x40000
#define REQUEST_MAX_QUEUED (32 * REQUEST_CHUNK_SIZE)
#define POST_DATA_SIZE 0x1000
#define MAX_URL_LENGTH 256
#define DEFAULT_WIDTH 1280
#define DEFAULT_HEIGHT 720
#define DEFAULT_WINDOW_NAME "FusionFall"
// we default to local server with 104 assets
#define FALLBACK_SRC_URL "http://cdn.dexlabs.systems/ff/big/beta-20100104/main.unity3d"
#define FALLBACK_ASSET_URL "http://cdn.dexlabs.systems/ff/big/beta-20100104/"
#define FALLBACK_SERVER_ADDRESS "127.0.0.1:23000"
#define ARRLEN(x) (sizeof(x)/sizeof(*x))
#define MIN(a, b) (a > b ? b : a)
typedef HRESULT (WINAPI *SetProcessDpiAwarenessFunc)(PROCESS_DPI_AWARENESS awareness);
typedef NPError (OSCALL *NP_GetEntryPointsFuncOS)(NPPluginFuncs*);
typedef NPError (OSCALL *NP_InitializeFuncOS)(NPNetscapeFuncs*);
typedef NPError (OSCALL *NP_ShutdownFuncOS)(void);
enum {
REQ_SRC_UNSET,
REQ_SRC_FILE,
REQ_SRC_HTTP,
REQ_SRC_CACHE,
REQ_SRC_MEMORY
};
typedef uint8_t RequestSource;
typedef struct Request Request;
typedef struct RequestChunk RequestChunk;
typedef struct Arguments Arguments;
struct RequestChunk {
RequestChunk *next;
DWORD size;
DWORD consumed;
uint8_t data[REQUEST_CHUNK_SIZE];
};
struct Request {
/* params */
void *notifyData;
bool doNotify;
char originalUrl[MAX_URL_LENGTH];
char url[MAX_URL_LENGTH];
bool isPost;
uint32_t postDataLen;
char postData[POST_DATA_SIZE];
/* state */
HANDLE readyEvent;
HANDLE spaceEvent;
char *mimeType;
RequestSource source;
NPStream *stream;
uint16_t streamType;
DWORD sizeHint;
DWORD bytesWritten;
DWORD bytesRead;
CRITICAL_SECTION queueLock;
RequestChunk *queueHead;
RequestChunk *queueTail;
size_t queuedBytes;
bool finished;
NPReason doneReason;
HANDLE doneEvent;
/* Shared flags: use interlocked operations */
LONG msgPending;
LONG aborted;
LONG readerDone;
LONG failed;
/* output (if set, write to file instead of plugin) */
HANDLE hOutFile;
/* handle */
union {
HANDLE hFile;
struct {
HINTERNET hConn;
HINTERNET hReq;
} http;
char *hData;
} handles;
};
struct Arguments {
char *mainPathOrAddress;
char *logPath;
char *serverAddress;
char *assetUrl;
char *endpointHost;
char *tegId;
char *authId;
char *windowName;
char *windowIcon;
uint32_t windowWidth;
uint32_t windowHeight;
bool useEndpointLoadingScreen;
bool verboseLogging;
bool forceVulkan;
bool forceOpenGl;
};
extern Arguments args;
extern NPP_t npp;
extern NPPluginFuncs pluginFuncs;
extern NPNetscapeFuncs netscapeFuncs;
extern NPWindow npWin;
extern HWND hwnd;
extern PTP_POOL threadpool;
extern UINT ioMsg;
void register_get_request(const char *url, bool doNotify, void *notifyData);
void register_post_request(const char *url, bool doNotify, void *notifyData, uint32_t postDataLen, const char *postData);
void register_temp_request(const char *url, HANDLE outFile, HANDLE onDone);
bool handle_io_progress(Request *req, bool final);
void release_request(Request *req);
void submit_request(Request *req);
void complete_request();
void init_network(char *mainSrcUrl);
void prepare_window(uint32_t width, uint32_t height, const char *iconFile);
void show_error_dialog(char *msg);
void open_link(char *url);
void message_loop(void);
void apply_vram_fix(void);
void init_logging(const char *logPath, bool verbose);
void dbglogmsg(const char *fmt, ...);
void logmsg(const char *fmt, ...);