Make network stuff publicly accesible, addresses #464 but not really.

This commit is contained in:
UnknownShadow200 2017-08-08 14:39:35 +10:00
parent 50c6a66082
commit 76bf08a61b
6 changed files with 19 additions and 13 deletions

View File

@ -31,8 +31,8 @@ namespace ClassicalSharp.Network {
Socket socket;
DateTime lastPacket;
byte lastOpcode;
internal NetReader reader;
internal NetWriter writer;
public NetReader reader;
public NetWriter writer;
internal ClassicProtocol classic;
internal CPEProtocol cpe;
@ -155,7 +155,7 @@ namespace ClassicalSharp.Network {
maxHandledPacket = Math.Max(opcode, maxHandledPacket);
}
internal void SendPacket() {
public void SendPacket() {
if (Disconnected) {
writer.index = 0;
return;

View File

@ -13,7 +13,6 @@ namespace ClassicalSharp {
public const string AppName = "ClassicalSharp 0.99.9.1";
public static string AppDirectory;
#if !LAUNCHER
[STAThread]
static void Main(string[] args) {
@ -78,6 +77,7 @@ namespace ClassicalSharp {
return;
} else if (port < ushort.MinValue || port > ushort.MaxValue) {
Utils.LogDebug("Specified port " + port + " is out of valid range.");
return;
}
string skinServer = args.Length >= 5 ? args[4] : "http://s3.amazonaws.com/MinecraftSkins/";

View File

@ -4,6 +4,8 @@
Copyright 2017 ClassicalSharp | Licensed under BSD-3
*/
#define Program_AppName "ClassicalSharp 0.99.9.2"
#define USE16_BIT FALSE
/* Max number of characters strings can have. */

View File

@ -51,6 +51,6 @@ DisplayDevice DisplayDevice_Make(DisplayResolution* curResolution);
void DisplayDevice_SetBounds(DisplayDevice* device, Rectangle* bounds);
/* The primary / default / main display device. */
DisplayDevice Primary;
DisplayDevice DisplayDevice_Default;
#endif

View File

@ -1,5 +1,9 @@
#include "Typedefs.h"
#include "ErrorHandler.h"
#include "Platform.h"
int main(int argc, char *argv[]) {
int main(int argc, char* argv[]) {
ErrorHandler_Init();
Platform_Init();
return 0;
}

View File

@ -4,15 +4,15 @@
#define WIN32_LEAN_AND_MEAN
/* TODO: These might be better off as a function. */
#define ErrorHandler_FailLog(raw_msg)\
#define ErrorHandler_WriteLogBody(raw_msg)\
UInt8 logMsgBuffer[String_BufferSize(2047)];\
String logMsg = String_FromRawBuffer(logMsgBuffer, 2047);\
String_AppendConstant(&logMsg, "ClassicalSharp crashed.\r\n");\
String_AppendConstant(&logMsg, "Location: ");\
String_AppendConstant(&logMsg, "Message: ");\
String_AppendConstant(&logMsg, raw_msg);\
String_AppendConstant(&logMsg, "\r\n");
#define ErrorHandler_PostLog()\
#define ErrorHandler_WriteLogEnd()\
String_AppendConstant(&logMsg, "\r\nPlease report the crash to github.com/UnknownShadow200/ClassicalSharp/issues so we can fix it.");
@ -26,8 +26,8 @@ void ErrorHandler_Log(String msg) {
void ErrorHandler_Fail(const UInt8* raw_msg) {
/* TODO: write to log file */
ErrorHandler_FailLog(raw_msg);
ErrorHandler_PostLog();
ErrorHandler_WriteLogBody(raw_msg);
ErrorHandler_WriteLogEnd();
HWND win = GetActiveWindow();
MessageBoxA(win, logMsg.buffer, "We're sorry", 0);
@ -36,11 +36,11 @@ void ErrorHandler_Fail(const UInt8* raw_msg) {
void ErrorHandler_FailWithCode(ReturnCode code, const UInt8* raw_msg) {
/* TODO: write to log file */
ErrorHandler_FailLog(raw_msg);
ErrorHandler_WriteLogBody(raw_msg);
String_AppendConstant(&logMsg, "Return code: ");
String_AppendInt32(&logMsg, (Int32)code);
String_AppendConstant(&logMsg, "\r\n");
ErrorHandler_PostLog();
ErrorHandler_WriteLogEnd();
HWND win = GetActiveWindow();
MessageBoxA(win, logMsg.buffer, "We're sorry", 0);