Jump to content

[patch][7544] uptime-table moved to characters-database


Guest invliD

Recommended Posts

done.

diff --git a/sql/mangos.sql b/sql/mangos.sql
index f9a7151..e90c91b 100644
--- a/sql/mangos.sql
+++ b/sql/mangos.sql
@@ -16833,28 +16833,6 @@ LOCK TABLES `transports` WRITE;
/*!40000 ALTER TABLE `transports` DISABLE KEYS */;
/*!40000 ALTER TABLE `transports` ENABLE KEYS */;
UNLOCK TABLES;
-
---
--- Table structure for table `uptime`
---
-
-DROP TABLE IF EXISTS `uptime`;
-CREATE TABLE `uptime` (
-  `starttime` bigint(20) unsigned NOT NULL default '0',
-  `startstring` varchar(64) NOT NULL default '',
-  `uptime` bigint(20) unsigned NOT NULL default '0',
-  `maxplayers` smallint(5) unsigned NOT NULL default '0',
-  PRIMARY KEY  (`starttime`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Uptime system';
-
---
--- Dumping data for table `uptime`
---
-
-LOCK TABLES `uptime` WRITE;
-/*!40000 ALTER TABLE `uptime` DISABLE KEYS */;
-/*!40000 ALTER TABLE `uptime` ENABLE KEYS */;
-UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
diff --git a/sql/realmd.sql b/sql/realmd.sql
index 4d08c77..58c93ca 100644
--- a/sql/realmd.sql
+++ b/sql/realmd.sql
@@ -174,6 +174,29 @@ INSERT INTO `realmlist` VALUES
(1,'MaNGOS','127.0.0.1',8085,1,0,1,0,0);
/*!40000 ALTER TABLE `realmlist` ENABLE KEYS */;
UNLOCK TABLES;
+
+--
+-- Table structure for table `uptime`
+--
+
+DROP TABLE IF EXISTS `uptime`;
+CREATE TABLE `uptime` (
+  `realmid` int(11) unsigned NOT NULL,
+  `starttime` bigint(20) unsigned NOT NULL default '0',
+  `startstring` varchar(64) NOT NULL default '',
+  `uptime` bigint(20) unsigned NOT NULL default '0',
+  `maxplayers` smallint(5) unsigned NOT NULL default '0',
+  PRIMARY KEY  (`starttime`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Uptime system';
+
+--
+-- Dumping data for table `uptime`
+--
+
+LOCK TABLES `uptime` WRITE;
+/*!40000 ALTER TABLE `uptime` DISABLE KEYS */;
+/*!40000 ALTER TABLE `uptime` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -184,4 +207,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

--- Dump completed on 2008-01-10 11:37:06
+-- Dump completed on 2008-01-10 11:37:06
\\ No newline at end of file
diff --git a/sql/updates/6979_01_mangos_uptime.sql b/sql/updates/6979_01_mangos_uptime.sql
new file mode 100644
index 0000000..80e7f09
--- /dev/null
+++ b/sql/updates/6979_01_mangos_uptime.sql
@@ -0,0 +1 @@
+DROP TABLE IF EXISTS `uptime`;
diff --git a/sql/updates/6979_02_realmd_uptime.sql b/sql/updates/6979_02_realmd_uptime.sql
new file mode 100644
index 0000000..605153f
--- /dev/null
+++ b/sql/updates/6979_02_characters_uptime.sql
@@ -0,0 +1,8 @@
+DROP TABLE IF EXISTS `uptime`;
+CREATE TABLE `uptime` (
+  `starttime` bigint(20) unsigned NOT NULL default '0',
+  `startstring` varchar(64) NOT NULL default '',
+  `uptime` bigint(20) unsigned NOT NULL default '0',
+  `maxplayers` smallint(5) unsigned NOT NULL default '0',
+  PRIMARY KEY  (`starttime`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Uptime system';
diff --git a/src/game/World.cpp b/src/game/World.cpp
index c4771d9..0b6c525 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -1307,8 +1307,9 @@ void World::SetInitialWorldSettings()
    sprintf( isoDate, "%04d-%02d-%02d %02d:%02d:%02d",
        local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec);

-    WorldDatabase.PExecute("INSERT INTO uptime (startstring, starttime, uptime) VALUES('%s', " I64FMTD ", 0)",
-        isoDate, uint64(m_startTime));
+    loginDatabase.PExecute("INSERT INTO uptime (realmid, startstring, starttime, "
+                           "uptime) VALUES(%u, '%s', " I64FMTD ", 0)", realmID,
+                           isoDate, uint64(m_startTime));

    m_timers[WUPDATE_OBJECTS].SetInterval(0);
    m_timers[WUPDATE_SESSIONS].SetInterval(0);
@@ -1518,7 +1519,9 @@ void World::Update(time_t diff)
        uint32 maxClientsNum = sWorld.GetMaxActiveSessionCount();

        m_timers[WUPDATE_UPTIME].Reset();
-        WorldDatabase.PExecute("UPDATE uptime SET uptime = %d, maxplayers = %d WHERE starttime = " I64FMTD, tmpDiff, maxClientsNum, uint64(m_startTime));
+        loginDatabase.PExecute("UPDATE uptime SET uptime = %d, maxplayers = %d "
+                               "WHERE starttime = " I64FMTD " AND realmid = %u",
+                               tmpDiff, maxClientsNum, uint64(m_startTime), realmID);
    }

    /// [*] Handle all other objects
diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h
index 328f7d8..d32f026 100644
--- a/src/shared/revision_nr.h
+++ b/src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
- #define REVISION_NR "6978"
+ #define REVISION_NR "6979"
#endif // __REVISION_NR_H__

Link to comment
Share on other sites

  • 2 months later...
commited in [7544]. Thx.

I removed realmid column, because you cannot use one character database for multiple realms.

character database? this patch works on the LOGIN database (the realm database), so you need the realmid

--- a/sql/realmd.sql

+++ b/sql/realmd.sql

+ loginDatabase.PExecute("INSERT INTO uptime (realmid, startstring, starttime, "

+ "uptime) VALUES(%u, '%s', " I64FMTD ", 0)", realmID,

+ isoDate, uint64(m_startTime));

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use