ID:266369
 
I am currently using this code to implement and test a host variable that I can use ingame:
var/HOST/host
HOST
var/global
client = null
key = ""
IP = 0
application = ""
found = 0
world
New()
..()
host = new /HOST
var/hostcheck_mobs = 0
for(var/mob/M in world)
if(M.client)
hostcheck_mobs += 1
world << hostcheck_mobs
if(hostcheck_mobs != 0)
host.client = new /client
host.key = ""
host.IP = world.address
host.application = "Dream Daemon"
host.found = 1
client
New()
..()
if(!host.found)
if(src.address == world.address)
host.client = src
host.key = src.key
host.IP = world.address
host.application = "Dream Seeker"
host.found = 1
verb/WhoHost()
world << "Host key: [host.key]"
world << "Host IP: [host.IP]"
world << "Your IP: [src.address]"
world << "Host Application: [host.application]"
world << "Found? [host.found]"


I get no runtime errors or compiled errors, but the host simply isn't defined on world.New() or client.New(). Seems strange to me, but I am probably missing something. Thank you for your time!

-Lord of Water
Lord of Water wrote:
I am currently using this code to implement and test a host variable that I can use ingame:
> var/HOST/host
> HOST
> var/global
> client = null
> key = ""
> IP = 0
> application = ""
> found = 0
> world
> New()
> ..()
> host = new /HOST
> var/hostcheck_mobs = 0
> for(var/mob/M in world)
> if(M.client)
> hostcheck_mobs += 1
> world << hostcheck_mobs
> if(hostcheck_mobs != 0)
> host.client = new /client
> host.key = ""
> host.IP = world.address
> host.application = "Dream Daemon"
> host.found = 1


I could be wrong, but I'm not so sure that any mobs would be connected to their clients yet when world/New() is run. Regardless, this check is unnecessary since it'll always happen below in client/New().
> client
> New()
> ..()
> if(!host.found)
> if(src.address == world.address)
> host.client = src
> host.key = src.key
> host.IP = world.address
> host.application = "Dream Seeker"
> host.found = 1

There are three possibilities you have to check. If src.address is null, then the client is the host using DreamSeeker. If src.address == world.address, the client is the host using DreamDaemon. Also if src.address == "127.0.0.1" then the client is also host using DreamDaemon.

My example works for me.