Skip to content

Commit

Permalink
Makes tracker DB null-safe.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen001 committed Apr 5, 2014
1 parent 033a58a commit 1be397a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/struct/TrackerManager.dm
Expand Up @@ -21,20 +21,20 @@ TrackerManager
return FALSE

findByIP(ip)
if(!ip) return
if(!ip) return new/TrackerEntry()
return trackerDB.findByIP(ip)

findByCkey(ckey)
ckey = ckey(ckey)
if(!ckey) return
if(!ckey) return new/TrackerEntry()
return trackerDB.findByCkey(ckey)

findByCID(cid)
if(!cid) return
if(!cid) return new/TrackerEntry()
return trackerDB.findByCID(cid)

findByClient(client/c)
if(!c || !istype(c, /client)) return
if(!c || !istype(c, /client)) return new/TrackerEntry()
return trackerDB.findByClient(c)

addClient(client/c)
Expand Down
10 changes: 7 additions & 3 deletions src/struct/TrackerPersistence.dm
Expand Up @@ -13,13 +13,13 @@ TrackerDB
return FALSE

findByIP(var/ip)
return list()
return new/TrackerEntry()

findByCkey(var/ckey)
return list()
return new/TrackerEntry()

findByCID(var/cid)
return list()
return new/TrackerEntry()

findByClient(var/client/C)
return findByIP(C.address)
Expand Down Expand Up @@ -81,6 +81,7 @@ TrackerDB/Savefile
if(length(sentries))
if(length(sentries) > 1) return __combineEntries(sentries)
else return sentries[1]
return new/TrackerEntry()

findByCkey(ckey)
var/list/sentries = list()
Expand All @@ -91,6 +92,7 @@ TrackerDB/Savefile
if(length(sentries))
if(length(sentries) > 1) return __combineEntries(sentries)
else return sentries[1]
return new/TrackerEntry()

findByCID(cid)
var/list/sentries = list()
Expand All @@ -101,6 +103,7 @@ TrackerDB/Savefile
if(length(sentries))
if(length(sentries) > 1) return __combineEntries(sentries)
else return sentries[1]
return new/TrackerEntry()

findByClient(client/c)
addClient(c)
Expand All @@ -114,6 +117,7 @@ TrackerDB/Savefile
if(length(sentries))
if(length(sentries) > 1) return __combineEntries(sentries)
else return sentries[1]
return new/TrackerEntry()

addClient(client/c)
if((c.ckey in all_ckeys) || (c.computer_id && (c.computer_id in all_cids)) || (c.address && (c.address in all_ips)))
Expand Down

0 comments on commit 1be397a

Please sign in to comment.