diff --git a/DreamTown/cgi-bin/area/update b/DreamTown/cgi-bin/area/update index 8c4b952..16af647 100644 --- a/DreamTown/cgi-bin/area/update +++ b/DreamTown/cgi-bin/area/update @@ -40,10 +40,16 @@ def TryUpdate(): cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,)) rows = cur.fetchone() username = rows[0] - if nextRubishSpawnTime == None: - nextRubishSpawnTime = math.floor(time.time()) + 600 - c.execute('UPDATE areaList SET NextRubishSpawnTime=? WHERE Name=? and AreaId=?',(nextRubishSpawnTime,username,areaId)) - c.execute('UPDATE areaList SET ActualAreaId=? WHERE Name=? and ActualAreaId IS NOT NULL',(areaId,username)) + + cur = c.execute('SELECT COUNT(1) from areaList WHERE Name=? and AreaId=?',(username,areaId)) + rows = cur.fetchone() + count = rows[0] + if count == 0: + c.execute('INSERT INTO areaList VALUES(?,NULL,?,?,NULL)',(username,areaId,nextRubishSpawnTime)) + c.execute('UPDATE areaList SET ActualAreaId=? WHERE Name=? and ActualAreaId IS NOT NULL',(areaId,username)) + else: + c.execute('UPDATE areaList SET NextRubishSpawnTime=? WHERE Name=? and AreaId=?',(nextRubishSpawnTime,username,areaId)) + c.execute('UPDATE areaList SET ActualAreaId=? WHERE Name=? and ActualAreaId IS NOT NULL',(areaId,username)) try: diff --git a/DreamTown/cgi-bin/harvestable/addContainer b/DreamTown/cgi-bin/harvestable/addContainer index f332d6d..f50693f 100644 --- a/DreamTown/cgi-bin/harvestable/addContainer +++ b/DreamTown/cgi-bin/harvestable/addContainer @@ -41,7 +41,7 @@ def TryAdd(): c.execute('DELETE from harvestList where Name=? and AreaId=? and containerName=?',(username,AreaId,ContainerName)) - c.execute('INSERT INTO harvestList VAlUES (?,?,NULL,?,NULL,?)',(username,harvestableTemplateId,containerName,AreaId)) + c.execute('INSERT INTO harvestList VAlUES (?,?,NULL,?,NULL,?)',(username,HarvestableTemplateId,ContainerName,AreaId)) try: diff --git a/DreamTown/cgi-bin/npc/update b/DreamTown/cgi-bin/npc/update index c290234..610e253 100644 --- a/DreamTown/cgi-bin/npc/update +++ b/DreamTown/cgi-bin/npc/update @@ -42,7 +42,14 @@ def TryUpdate(): username = rows[0] - c.execute('UPDATE npcList SET RequestLevel=?,Pool=?, NextTimestamp=? WHERE Name=? AND CharacterId=?',(RequestLevel,Pool,NextTimestamp,username,CharacterId)) + + cur = c.execute('SELECT COUNT(1) from npcList WHERE Name=? AND CharacterId=?',(username,CharacterId)) + rows = cur.fetchone() + count = rows[0] + if count == 0: + c.execute('INSERT INTO npcList VALUES(?,?,?,?,?)',(username,CharacterId,NextTimestamp,Pool,RequestLevel)) + else: + c.execute('UPDATE npcList SET RequestLevel=?,Pool=?, NextTimestamp=? WHERE Name=? AND CharacterId=?',(RequestLevel,Pool,NextTimestamp,username,CharacterId)) try: diff --git a/DreamTown/cgi-bin/relation/update b/DreamTown/cgi-bin/relation/update index 8b44441..b8c4721 100644 --- a/DreamTown/cgi-bin/relation/update +++ b/DreamTown/cgi-bin/relation/update @@ -40,8 +40,13 @@ def TryUpdate(): rows = cur.fetchone() username = rows[0] - - c.execute('UPDATE relationsList SET Level=?,Progress=? WHERE Name=? AND CharacterId=?',(Level,Progress,username,CharacterId)) + cur = c.execute('SELECT COUNT(1) from relationsList WHERE Name=? AND CharacterId=?',(username,CharacterId)) + rows = cur.fetchone() + count = rows[0] + if count == 0: + c.execute('INSERT INTO relationsList VALUES(?,?,?,?)',(username,CharacterId,Level,Progress)) + else: + c.execute('UPDATE relationsList SET Level=?,Progress=? WHERE Name=? AND CharacterId=?',(Level,Progress,username,CharacterId)) try: diff --git a/DreamTown/cgi-bin/rubish/remove b/DreamTown/cgi-bin/rubish/remove index d9f644f..da72157 100644 --- a/DreamTown/cgi-bin/rubish/remove +++ b/DreamTown/cgi-bin/rubish/remove @@ -38,7 +38,7 @@ def TryRemove(): username = rows[0] - c.execute('DELETE from rubishList WHERE Name=? and Id=?',(username,rubishId)) + c.execute('DELETE from rubishList WHERE Name=? and Id=?',(username,Id)) return 0 diff --git a/DreamTown/cgi-bin/scenario/update b/DreamTown/cgi-bin/scenario/update index e604083..464393b 100644 --- a/DreamTown/cgi-bin/scenario/update +++ b/DreamTown/cgi-bin/scenario/update @@ -39,8 +39,14 @@ def TryUpdate(): cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,)) rows = cur.fetchone() username = rows[0] - - c.execute('UPDATE scenario SET CustomData=?,StepId=? WHERE Name=? AND ScenarioId=?',(CustomData,StepId,username,ScenarioId)) + + cur = c.execute('SELECT COUNT(1) from scenario WHERE Name=? AND ScenarioId=?',(username,ScenarioId)) + rows = cur.fetchone() + count = rows[0] + if count == 0: + c.execute('INSERT INTO scenario VALUES(?,?,?,?,0)',(username,ScenarioId,CustomData,StepId)) + else: + c.execute('UPDATE scenario SET CustomData=?,StepId=? WHERE Name=? AND ScenarioId=?',(CustomData,StepId,username,ScenarioId)) try: