0

I'm writing some code that uses a class to interact with a matchmaking server using TcpLink. Since I need to access a single reference to an object of this class throughout the code, I've been saving a reference to the object in the PlayerController class and accessing it throughout the program using the function GetPC. My question is, is it safe to call this function in a subclass of GameReplicationInfo? If it isn't possible, then what are my alternatives for inter-class data transfer? The class instance needs to be accessible from a variety of different places, including instances of GFxMoviePlayer, PlayerController, and, most of all, GameReplicationInfo itself.

4

2 回答 2

2

如果对象只需要从本地播放器访问,存储引用并仅访问本地播放器控制器中的引用应该没问题,并且是比配置文件更好的解决方案。确保始终使用本地玩家控制器,并且您不应该期望在关卡/服务器切换或连接后保留您的对象。我自己做了一个 Tcplink 匹配服务器,知道 1) 最终你应该计划将 tcplink 与你自己的从在线子系统中提取的类结合起来,2) 同时播放器控制器方法将起作用。

于 2012-05-14T20:33:36.800 回答
0

叹息,没有答案。我想我只是将值保存在配置文件中,因为速度并不是真正的本质。

于 2012-04-28T23:36:15.530 回答