OpenClonk
main.cpp File Reference
#include "C4Include.h"
#include "netpuncher/C4PuncherHash.h"
#include "netpuncher/C4PuncherPacket.h"
#include "network/C4Network2.h"
#include <random>
#include <unordered_map>
Include dependency graph for main.cpp:

Go to the source code of this file.

Classes

class  C4PuncherServer
 

Functions

int main (int argc, char *argv[])
 
void RecordRandom (uint32_t range, uint32_t val)
 

Variables

C4PuncherServer Puncher
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 85 of file main.cpp.

86 {
87  // Log
88  printf("Starting puncher...\n");
89 
90  // Get port
91  uint16_t iPort = C4NetStdPortPuncher;
92  if (argc == 2)
93  {
94  iPort = strtoul(argv[1], nullptr, 10);
95  if (!iPort) iPort = C4NetStdPortPuncher;
96  }
97 
98  // Initialize
99  if (!Puncher.Init(iPort))
100  {
101  fprintf(stderr, "Could not initialize puncher: %s", Puncher.GetError());
102  return 1;
103  }
104 
105  // Log
106  printf("Listening on port %d...\n", iPort);
107 
108  // Execute forever
109  for (;;)
110  {
111  Puncher.ExecuteUntil(-1);
112  fprintf(stderr, "ERROR: %s\n", Puncher.GetError());
113  }
114 
115  return 0;
116 }
const int16_t C4NetStdPortPuncher
Definition: C4Network2.h:33
virtual const char * GetError() const
Definition: C4NetIO.h:286
bool Init(uint16_t iPort=addr_t::IPPORT_NONE) override
Definition: C4NetIO.cpp:2472
bool ExecuteUntil(int iTimeout=-1)
C4PuncherServer Puncher

References C4NetStdPortPuncher, StdSchedulerProc::ExecuteUntil(), C4NetIO::GetError(), C4NetIOUDP::Init(), and Puncher.

Here is the call graph for this function:

◆ RecordRandom()

void RecordRandom ( uint32_t  range,
uint32_t  val 
)

Definition at line 119 of file main.cpp.

119 {}

References AddDbgRec(), C4RCRandom::Cnt, Config, C4ConfigGeneral::DebugRec, C4Config::General, RandomCount, C4RCRandom::Range, RCT_Random, and C4RCRandom::Val.

Here is the call graph for this function:

Variable Documentation

◆ Puncher

C4PuncherServer Puncher

Referenced by main().