Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

raknet DNO problem

Started by terryleung 0 replies 750+ views
Original Post
terryleung
terryleung
have some problem in DNO i set it up without syntax and link error however, when the server/client create a DNO the otherside dont created one this is my network sys object Code: CNetworkSys::CNetworkSys(bool isServer,char* ip, int port) { server=isServer; rakClient=RakNetworkFactory::GetRakClientInterface(); rakServer=RakNetworkFactory::GetRakServerInterface(); // Crude interface if (!isServer) { // Holds user data char clientPort[30]; // Get our input strcpy(clientPort, "0"); // Connecting the client is very simple. 0 means we don't care about // a connectionValidationInteger, and false for low priority threads bool b = rakClient->Connect("127.0.0.1",60000, 0, 0, 30); /*if (b) MessageBox(NULL,NULL,"Attempting connection",MB_OK); else*/ if (!b) { MessageBox(NULL,"Bad connection attempt. Terminating.","Error",MB_OK); exit(1); } // *** DISTRIBUTED OBJECT USER NOTE #7 *** // To use distributed objects we have to register our network instance with the distributed object manager DistributedNetworkObjectManager::Instance()->RegisterRakClientInterface(rakClient); } else { // Holds user data char portstring[30]; // A server // Starting the server is very simple. 2 players allowed. // 0 means we don't care about a connectionValidationInteger, and false // for low priority threads bool b = rakServer->Start(2, 0, 30, 60000); /* if (b) MessageBox(NULL,NULL,"Server started, waiting for connections.",MB_OK); else*/ if (!b) { MessageBox(NULL,"Server failed to start. Terminating.","ERROR",MB_OK); exit(1); } // *** DISTRIBUTED OBJECT USER NOTE #7 *** // To use distributed objects we have to register our network instance with the distributed object manager DistributedNetworkObjectManager::Instance()->RegisterRakServerInterface(rakServer); } } CNetworkSys::~CNetworkSys(void) { if (rakClient!=NULL) RakNetworkFactory::DestroyRakClientInterface(rakClient); if (rakServer!=NULL) RakNetworkFactory::DestroyRakServerInterface(rakServer); } void CNetworkSys::update() { if (server) rakServerMultiplayer.ProcessPackets(rakServer); else rakClientMultiplayer.ProcessPackets(rakClient); } This is my DNO Code: class CPlayer : public CEntity, public DistributedNetworkObject { void update {UpdateDistributedObject("CPlayer");} ....skip the definition... REGISTER_2_DISTRIBUTED_OBJECT_MEMBERS(DistributedNetworkObject, DOM_INTERPOLATE_UNCOMPRESSED, /*CConfigFile::isServer?DOM_SERVER_AUTHORITATIVE:*/DOM_CLIENT_AUTHORITATIVE, CVector,position, DOM_INTERPOLATE_UNCOMPRESSED, /*CConfigFile::isServer?DOM_SERVER_AUTHORITATIVE:*/DOM_CLIENT_AUTHORITATIVE, CVector,velocity ) }; i first create a networkSys instance then register the CPlayer class //not shown in the above code after this the CPlayer is created and in each frame, both update of networksys and cplayer is called i tried to put a MessageBox at the constructor of cplayer class it should appear twice each time at each side but it only appears once therefore, i know only the local one is created also, i have try to call a function to know the collected player number i am sure they get collected anyone know how to fix it?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.