[C++, PY] Minimap alá FPS meg PING mérő

Started by 66Dragon99, 2020-10-10, 19:27:14

2020-10-10, 19:27:14 Last Edit: 2020-10-18, 18:46:47 by 66Dragon99
Tipp: biztonsági mentést csinálj!
UPDATE: Tabulátorokra vigyázz! pl game.py

[spoiler=Kliens]Root
game.py
#keresd az
class GameWindow(ui.ScriptWindow):
-ban
self.__ProcessPreservedServerCommand()

#Rakd alá új üres sorba
self.pingLine = None
if app.ENABLE_PINGTIME:
self.pingLine = ui.TextLine()
self.pingLine.SetFontName(localeInfo.UI_DEF_FONT_LARGE)
self.pingLine.SetFontColor(1.0,1.0,1.0)
self.pingLine.SetPosition((wndMgr.GetScreenWidth() - 130) / 2, 207)

         
#Keresd a
def Close(self):
-ben ezt
self.interface=None

#Rakd alá új üres sorba
if app.ENABLE_PINGTIME:
self.pingLine = None


#Keresd a
def __BuildDebugInfo(self):
-ben ezt:
self.ViewDistance.SetPosition(0, 0)
      
#Rakd alá új üres sorba ezeket:
if app.ENABLE_PINGTIME:
self.pingLine.SetWindowHorizontalAlignCenter()
self.pingLine.SetHorizontalAlignCenter()
self.pingLine.SetFeather()
self.pingLine.SetOutline()
self.pingLine.Show()

         
#keress a
def OnUpdate(self):
-ben erre:

self.interface.BUILD_OnUpdate()

#Alá új sorba kerüljenek ezek
if app.ENABLE_PINGTIME:
nPing = app.GetPingTime()
self.pingLine.SetText("PING: %s" % (nPing))

game.py mentése
root visszacsomagolása.[/spoiler]

Indítóforrás:
[spoiler=Locale_inc.h]a lista elemei alá adod:
#define ENABLE_PINGTIME[/spoiler]

[spoiler=PythonApplication.cpp]//Keresd
[code]#include "CheckLatestFiles.h"

//alá új sorba
#ifdef ENABLE_PINGTIME
#include "PingManager.h"
#endif


//keresd
CPythonApplication::CPythonApplication() :

//keresd:
m_dwRenderFPS(0),
add alá:

#ifdef ENABLE_PINGTIME
m_dwPingTime(0),
#endif


//Keresd
bool CPythonApplication::Process()

//a
if (ELTimer_GetMSec() - s_dwCheckTime > 1000)
alá kerüljön a következő rész:
#ifdef ENABLE_PINGTIME
static DWORD s_dwPingTime = 0;
static DWORD s_dwCheckTime2 = ELTimer_GetMSec();

if (ELTimer_GetMSec() - s_dwCheckTime2 > 5000)
{

CPingManager CPingManager;
m_dwPingTime = CPingManager.PingTimeRev();
s_dwCheckTime2 = ELTimer_GetMSec();
}
#endif
[/code][/spoiler]

[spoiler=PythonApplication.h]//Keresd
[code] DWORD GetRenderFPS() { return m_dwRenderFPS; }


//Alá új sorba
#ifdef ENABLE_PINGTIME
DWORD GetPingTime() { return m_dwPingTime; }

#endif

//Keresd
DWORD m_dwFaceCount;

//Alá új sorba
#ifdef ENABLE_PINGTIME
DWORD m_dwPingTime;
#endif

[/code][/spoiler]
[spoiler=PythonApplicationModule.cpp]//Keresd
[code]PyObject * appGetRenderFPS(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", CPythonApplication::Instance().GetRenderFPS());
}


//Alá új sorba rakd
#ifdef ENABLE_PINGTIME
PyObject * appGetPingTime(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", CPythonApplication::Instance().GetPingTime());
}
#endif


//Keresd
{ "GetRenderFPS", appGetRenderFPS, METH_VARARGS },[code]

//Alá új sorba rakd
[code]#ifdef ENABLE_PINGTIME
{ "GetPingTime", appGetPingTime, METH_VARARGS },
#endif


//Keresd
#ifdef ENABLE_NEW_EQUIPMENT_SYSTEM
PyModule_AddIntConstant(poModule, "ENABLE_NEW_EQUIPMENT_SYSTEM", 1);
#else
PyModule_AddIntConstant(poModule, "ENABLE_NEW_EQUIPMENT_SYSTEM", 0);
#endif


//Alá új sorba rakd
#ifdef ENABLE_PINGTIME
PyModule_AddIntConstant(poModule, "ENABLE_PINGTIME", 1);
#else
PyModule_AddIntConstant(poModule, "ENABLE_PINGTIME", 0);
#endif
[/code][/spoiler]

[spoiler=PythonNetworkStreamModule.py]
//Keresd
[code]static std::string gs_stServerInfo;

//Alá új sorba rakd
#ifdef ENABLE_PINGTIME
const char * global_ip;
#endif


//Keresd
PyObject* netConnectToAccountServer(PyObject* poSelf, PyObject* poArgs)

//Szerkeszd így
PyObject* netConnectToAccountServer(PyObject* poSelf, PyObject* poArgs)
{
char* addr;
if (!PyTuple_GetString(poArgs, 0, &addr))
return Py_BuildException();

int port;
if (!PyTuple_GetInteger(poArgs, 1, &port))
return Py_BuildException();

char* account_addr;
if (!PyTuple_GetString(poArgs, 2, &account_addr))
return Py_BuildException();

int account_port;
if (!PyTuple_GetInteger(poArgs, 3, &account_port))
return Py_BuildException();

#ifdef ENABLE_PINGTIME
global_ip = addr;
#endif

CAccountConnector & rkAccountConnector = CAccountConnector::Instance();
rkAccountConnector.Connect(addr, port, account_addr, account_port);

return Py_BuildNone();
}
[/code][/spoiler]


Hozd létre a kövi fájlt az előzők melletti mappában
[spoiler=Pingmanager.cpp]#include "PingManager.h"
#ifdef ENABLE_PINGTIME
#include <iphlpapi.h>
#include <icmpapi.h>
#include <stdio.h>

#pragma comment(lib, "iphlpapi.lib")
#pragma comment(lib, "ws2_32.lib")

extern const char * global_ip;

int __cdecl CPingManager::PingTimeRev()  {
static HANDLE hIcmpFile;
static unsigned long ipaddr = INADDR_NONE;
static DWORD dwRetVal = 0;
static char SendData[32] = "Data Buffer";
static LPVOID ReplyBuffer = NULL;
static DWORD ReplySize = 0;

ipaddr = inet_addr(global_ip);

if (ipaddr == INADDR_NONE) {
return 1;
}

hIcmpFile = IcmpCreateFile();

if (hIcmpFile == INVALID_HANDLE_VALUE) {
return 1;
}

ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData);
ReplyBuffer = (VOID*)malloc(ReplySize);

if (ReplyBuffer == NULL) {
return 1;
}

dwRetVal = IcmpSendEcho(hIcmpFile, ipaddr, SendData, sizeof(SendData), NULL, ReplyBuffer, ReplySize, 1000);
PICMP_ECHO_REPLY pEchoReply = (PICMP_ECHO_REPLY)ReplyBuffer;

if (dwRetVal != 0) {
PICMP_ECHO_REPLY pEchoReply = (PICMP_ECHO_REPLY)ReplyBuffer;
return pEchoReply->RoundTripTime;
}

else {
return 0;
}
}
#endif

[/spoiler]

Hozd létre a kövi fájlt az előzők melletti mappában
[spoiler=Pingmanager.h]#pragma once
#include "StdAfx.h"

#ifdef ENABLE_PINGTIME
class CPingManager
{

public:
int __cdecl CPingManager::PingTimeRev();

};
#endif

[/spoiler]

UPDATE: Tabulátorokra vigyázz! pl game.py

Kész vagyunk, ha mentetted a dolgokat és minden a helyén vank, akkor buildelheted a forrásodat,
hiba észlelése esetén: itt nyithatsz segítségkérő témát -> https://metin2hungary.net/index.php?action=post;board=42.0


http://www.kepfeltoltes.eu/view.php?filename=112lol.png lol értem már mér lett ratyi a metinpunk2077