Jump to content

[SOLVED] how to get argc and argv[] and make a background task


photo

Recommended Posts

Hey Guys,

i am working on a network system for unigine but i need the following things:

argc and argv[]

i want to have a task running each frame or in the background and i know unigine takes argc and argv[] in the main.cpp but i dont know how to pass it to the appworldlogic.h or .cpp

here is a snippet of the code.

image.thumb.png.3ea6a1e6da509d3ece01db56a364e9a7.png

maybe there is a way to make it a global value through the code.

and this snippet is what i need to run each frame or in the background:

		server.SendPackets();

		server.ReceivePackets();

		time += deltaTime;

		server.AdvanceTime(time);

		if (!server.IsRunning())
			break;

		yojimbo_sleep(deltaTime);

the server runs but i need this specific snippet of code to always run, that is why i need argc and argv[] to initialize it first.

 

Link to comment

topic can be solved!

some1 from discord helped me with this piece of code:

 

const auto arg_num = Unigine::Engine::get()->getNumArgs();
for (int i = 0; i < arg_num; ++i)
    const auto arg = Unigine::Engine::get()->getArg(i);

and i was able to solve my problem by making these 2 lines:
 

	int argc = Unigine::Engine::get()->getNumArgs();
	char* argv = (char*)Unigine::Engine::get()->getArg(0);

and now my client can connect to the server :Dimage.thumb.png.122f926a2c33548f003f3774088bd47c.png
 

Link to comment
  • silent changed the title to [SOLVED] how to get argc and argv[] and make a background task
×
×
  • Create New...