From 60a301a93b6057bb2c54ac04a7c38c38389037b3 Mon Sep 17 00:00:00 2001 From: Dark1-dev Date: Wed, 1 Mar 2023 21:30:57 +0600 Subject: Add files via upload --- src/Protocols/GameSpy0/gamespy0.cpp | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/Protocols/GameSpy0/gamespy0.cpp (limited to 'src/Protocols/GameSpy0/gamespy0.cpp') diff --git a/src/Protocols/GameSpy0/gamespy0.cpp b/src/Protocols/GameSpy0/gamespy0.cpp new file mode 100644 index 0000000..6595d4a --- /dev/null +++ b/src/Protocols/GameSpy0/gamespy0.cpp @@ -0,0 +1,51 @@ +#include "gamespy0.h" + +QMultiHash parseGameSpy0Buffer(const QString &bufferString) +{ + // initialise output hash + QMultiHash queryStringHash; + + // split on backslash + QStringList bufferStringList = bufferString.split('\\', QString::KeepEmptyParts); + + // iterate through all items + QListIterator property (bufferStringList); + + // the first element is always empty -- skip it + if ( property.hasNext() ) + { + property.next(); + } + + // store as key -> value + while ( property.hasNext() ) + { + // unify valid keys + QString key = overrideKey( property.next().trimmed() ); + + // see if a value for this key exists + if ( ! property.hasNext() ) + break; + + // get value + QString value = property.next().trimmed(); + + // insert to return hash + queryStringHash.insert(key, value); + } + + // override gamename + if ( queryStringHash.contains("gamename") ) + { + QList gn = queryStringHash.values("gamename"); + queryStringHash.remove("gamename"); + + // read backwards to preserve element order + for (int i = gn.size()-1; i >= 0; i--) + { + queryStringHash.insert("gamename", overrideGamename( gn.value(i) ) ); + } + } + + return queryStringHash; +} -- cgit v1.2.3