Fix for MSVC

This commit is contained in:
yvt 2017-02-25 10:51:47 -08:00
parent 7bf5becdc8
commit d78b91a92f
2 changed files with 17 additions and 5 deletions

View File

@ -89,6 +89,7 @@ GCC 4.9 / Clang 3.2 or later is recommended because OpenSpades relies on C++11 f
* For OpenAL audio: `openal32.dll`
* For YSR audio: `YSRSpades.dll`, `libgcc_s_dw2-1.dll`, `libstdc++-6.dll`, `pthreadGC2.dll`
10. Download the [Non-free pak](https://github.com/yvt/openspades-paks/releases/download/r33/OpenSpadesDevPackage-r33.zip), extract it, and copy `Nonfree/pak000-Nonfree.pak` to the `Resources` folder inside your build output directory, which is probably `E:/Projects/openspades/openspades.msvc/bin/BUILD_TYPE/Resources`. You can also copy the paks contained in `Official Mods/` folder of OpenSpades 0.0.12b to add more fonts and improve localization support of your build.
11. Copy `Resources/PackageInfo.json` to the `Resources` folder inside your build output directory.
### On Mac OS X (with Xcode)
1. Get the latest version of Xcode and OpenSpades source.

View File

@ -113,6 +113,13 @@ namespace spades {
};
class PackageUpdateManager::HttpUpdateFeed : public UpdateFeed {
// Protected members of the base class is only accessible by
// the current object, so...
void ReturnErrorVeneer(const std::string &reason) {
ReturnError(reason);
}
class RequestThread : public Thread {
public:
RequestThread(HttpUpdateFeed &parent) : m_parent{parent} {}
@ -127,7 +134,7 @@ namespace spades {
curl_easy_setopt(
curl.get(), CURLOPT_WRITEFUNCTION,
static_cast<unsigned long (*)(void *, unsigned long, unsigned long, void *)>(
[](void *ptr, size_t size, size_t nmemb, void *data) {
[](void *ptr, unsigned long size, unsigned long nmemb, void *data) -> unsigned long {
size_t dataSize = size * nmemb;
reinterpret_cast<std::string *>(data)->append(
reinterpret_cast<const char *>(ptr), dataSize);
@ -139,15 +146,15 @@ namespace spades {
m_parent.SetupCURLRequest(curl.get());
if (curl_easy_perform(curl.get())) {
m_parent.ReturnError("HTTP request error.");
m_parent.ReturnErrorVeneer("HTTP request error.");
return;
}
m_parent.ProcessResponse(responseBuffer);
} catch (std::exception &ex) {
m_parent.ReturnError(ex.what());
m_parent.ReturnErrorVeneer(ex.what());
} catch (...) {
m_parent.ReturnError("Unknown error.");
m_parent.ReturnErrorVeneer("Unknown error.");
}
}
@ -164,7 +171,11 @@ namespace spades {
}
m_thread->Start();
}
~HttpUpdateFeed() override { m_thread->Join(); }
~HttpUpdateFeed() override {
if (m_thread) {
m_thread->Join();
}
}
protected:
HttpUpdateFeed(PackageUpdateManager &packageUpdateManager)