Announcement

Collapse
No announcement yet.

TCP Link between game server and AI server

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #31
    Ok it's 5am and I'm beat now, but here's the result of the night's programming...

    I've created duplicates of UT2k4's irc client within the Wanderlust package. The reason I'm using the duplicates and not the originals is that the originals have to do with a completely different type of interface but have a lot of functions that look like they'll be useful. My version consists of two classes, WLIRCLink and WanderlustIRCController that essentially mirror UT2k4IRCLink and UT2k4IRC_System respectively except I've ripped out all the GUI stuff. unfortunately I think I've ripped out a little too much because it's not getting connected. Here's what I've got...

    WLIRCLink.uc
    Code:
    class WLIRCLink extends BufferedTCPLink;
    
    var IpAddr			ServerIpAddr;
    
    var string			ServerAddress;
    var int				ServerPort;
    
    var string			NickName;
    var string			UserIdent;
    var string			FullName;
    var string			DefaultChannel;
    
    var localized string InvalidAddressText;
    var localized string ErrorBindingText;
    var localized string ResolveFailedText;
    var localized string ConnectedText;
    var localized string ConnectingToText;
    var localized string TimeOutError;
    var localized string InviteString;
    
    var WanderlustIRCController SystemPage;
    
    ...
    
    function Connect(WanderlustIRCController InSystemPage, string InServer, string InNickName, string InUserIdent, string InFullName, string InDefaultChannel)
    {
    	local int i;
    
        log("WanderlustIRCController Connect:"@InServer@InNickName@InUserIdent@InFullName@InDefaultChannel,'IRC');
    
    	SystemPage = InSystemPage;
    	NickName = InNickName;
    	FullName = InFullName;
    	UserIdent = InUserIdent;
    	DefaultChannel = InDefaultChannel;
    
        log(NickName);
        log(FullName);
        log(UserIdent);
        log(DefaultChannel);
    
    	i = InStr(InServer, ":");
    	if(i == -1)
    	{
    		ServerAddress = InServer;
    		ServerPort = 6668;
    	}
    	else
    	{
    		ServerAddress = Left(InServer, i);
    		ServerPort = Int(Mid(InServer, i+1));
    	}
    
    	ResetBuffer();
    	ServerIpAddr.Port = ServerPort;
    	SetTimer(20, False);
    	SystemPage.SystemText( ConnectingToText@ServerAddress );
    	Resolve( ServerAddress );
    }
    
    ....
    WanderlustIRCController.uc
    Code:
    class WanderlustIRCController extends Actor;
    
    var         string              LinkClassName;
    var         WLIRCLink           Link;
    
    var         WLIRCLink.IpAddr	ServerIpAddr;
    
    var         string			    ServerAddress;
    var         int				    ServerPort;
    
    var         array<UT2K4IRC_Channel>		Channels;
    
    var         UT2K4Browser_IRC    tp_Main;
    
    var			string				TestIRCString, LastServer;
    var 		int 				CurChannel, PrevChannel;
    var	private bool                bConnected, bAway,
    								bSysInitialized;
    
    var         config     string   NewNickMenu;
    var()       config     string   OldPlayerName, NickName,
    								 FullName, UserIdent, DefaultChannel, DefaultChannelPassword;
    var	        config     string   ChanKeyMenu;
    
    ...
    
    function PreBeginPlay()
    {
    	super.PreBeginPlay();
        Link = spawn(class'WLIRCLink ');
    }
    
    function Getconnected()
    {
    Connect("irc.slothworks.com");
    log("Attempted to connect");
    }
    
    ...
    
    function bool Connect(string NewServer)
    {
    	local WLIRCLink NewLink;
    log("Got into the Connect function");
    
    log(NewServer);
        if (NewServer == "")
    log("NewServer does not exist");
        	return false;
    
    log("NewServer exists");
    
    	NewLink = CreateNewLink();
    	if ( NewLink == None )
    log("NewLink does not exist");
        	return false;
    
    log("NewLink exists");
    
    	OldPlayerName = NickName;
    	FullName = NickName;
    
    	UpdateIdent();
    
    	// Implement perform buffer here - use delegate OnConnect()
    	NewLink.Connect( Self, NewServer, NickName, UserIdent, FullName, GetDefaultChannel() );
    	ChangeConnectStatus( True );
    
    	SetTimer( 1.0, True );
    	return true;
    }
    
    ...
    Wanderlust_Game.uc
    Code:
    class Wanderlust_Game extends DeathMatch
    	config(Wanderlust);
    
    var() 	config	bool			bLogDebug;
    
    var string WLInitString;
    var string WLStatusString;
    var string WLShutdownString;
    
    var WanderlustServerTimer m_Timer;
    var WanderlustIRCController WL_IRCControl;
    
    event InitGame( string Options, out string Error )
    {
    	super.InitGame(Options, Error);
    
        WLInitString = "Initializing the Wanderlust Game";
        WanderlustSendMessage (WLInitString);
    
        m_Timer = spawn(class'WanderlustServerTimer');
        m_Timer.m_game = self;
    
        WL_IRCControl = spawn(class'WanderlustIRCController');
        WL_IRCControl.GetConnected();
    
        if(bLogDebug)
        {
        }
    }
    
    event Timer()
    {
    if (m_Timer.m_game != none)
    	m_Timer.m_game.ServerTimerProxy();
    }
    
    ...
    Wanderlust.log
    ...

    Log: Browse: DM-Rankin?Name=Player?Class=Engine.Pawn?Character=Jak ob?team=255?game=Wanderlust.Wanderlust_Game
    Log: Collecting garbage
    Log: Purging garbage
    Log: (Karma): Level Karma Terminated.
    Log: Garbage: objects: 42326->38719; refs: 497319
    Log: Game class is 'Wanderlust_Game'
    Log: Bringing Level DM-Rankin.myLevel up for play (0) appSeconds: 48.148000...
    Log: (Karma): Autodetecting CPU for SSE
    Log: (Karma): Using SSE Optimizations
    ScriptLog: GameInfo::InitGame : bEnableStatLogging False
    ScriptLog: Initializing the Wanderlust Game
    ScriptLog: Got into the Connect function
    ScriptLog: irc.slothworks.com
    ScriptLog: Attempted to connect
    ScriptLog: PreBeginPlay
    ScriptLog: PostBeginPlay
    Log: Spawning new actor for Viewport WindowsViewport
    ScriptLog: New Player Player id=2ae48f93318bca881b441ae441b4c490
    Log: Precaching: DM-Rankin.LevelInfo0
    Log: Static mesh batches: 11352456 vertex bytes, 914784 index bytes
    Log: Allocating 16384 byte dynamic index buffer.
    Log: Finished precaching geometry in 3.769 seconds
    Log: Finished precaching textures in 1.624 seconds
    ScriptLog: test
    ScriptLog: test
    ScriptLog: test
    ScriptLog: test
    ScriptLog: test

    ...
    It apparently gets about as far as if (NewServer == "") in WanderlustIRCController and returns false without printing any of the text to the log. I'm sooooo stumped this time...

    Comment


      #32
      Ok I found the culprit: NewLink is not being defined like it's supposed to be.

      WanderlustIRCController.uc
      Code:
      ...
      
      function bool Connect(string NewServer)
      {
      	local WLIRCLink NewLink;
      log("Got into the Connect function");
      
      log(NewServer);
          if (NewServer == "")
      log("NewServer does not exist");
          	return false;
      
      log("NewServer exists");
      
      	NewLink = CreateNewLink();
      	if ( NewLink == None )
      log("NewLink does not exist");
          	return false;
      
      log("NewLink exists");
      
      	OldPlayerName = NickName;
      	FullName = NickName;
      
      	UpdateIdent();
      
      	// Implement perform buffer here - use delegate OnConnect()
      	NewLink.Connect( Self, NewServer, NickName, UserIdent, FullName, GetDefaultChannel() );
      	ChangeConnectStatus( True );
      
      	SetTimer( 1.0, True );
      	return true;
      }
      
      ...
      
      protected function WLIRCLink CreateNewLink()
      {
      	local class<WLIRCLink> NewLinkClass;
      	local WLIRCLink NewLink;
      	if ( LinkClassName != "" )
      		NewLinkClass = class<WLIRCLink>(DynamicLoadObject( LinkClassName, class'class'));
              log(NewLink);
          return NewLink;
      }
      
      ...
      Returns the following to the log:

      ScriptLog: GameInfo::InitGame : bEnableStatLogging False
      ScriptLog: Initializing the Wanderlust Game
      ScriptLog: Got into the Connect function
      ScriptLog: irc.slothworks.com
      ScriptLog: None
      ScriptLog: NewLink does not exist
      ScriptLog: Attempted to connect
      ScriptLog: PreBeginPlay
      Edit: OMG I fixed it, it works!!! Now all that's left is telling it what to say and what to do when there's a response! lol

      Comment

      Working...
      X