summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/palette.cpp9
-rw-r--r--src/main.cpp2
-rw-r--r--src/net/manaserv/manaserv_protocol.h10
-rw-r--r--src/net/manaserv/partyhandler.cpp78
-rw-r--r--src/particleemitterprop.h4
-rw-r--r--src/party.cpp4
-rw-r--r--src/utils/specialfolder.cpp2
7 files changed, 67 insertions, 42 deletions
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index 9ddbb34d..53bb505e 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -32,6 +32,7 @@
#include <math.h>
+static const double PI = 3.14159265;
const gcn::Color Palette::BLACK = gcn::Color(0, 0, 0);
Palette::Palettes Palette::mInstances;
@@ -116,7 +117,7 @@ void Palette::advanceGradient()
if (mGradVector[i]->grad == PULSE)
{
- colVal = (int) (255.0 * sin(M_PI * colIndex / numOfColors));
+ colVal = (int) (255.0 * sin(PI * colIndex / numOfColors));
const gcn::Color &col = mGradVector[i]->testColor;
@@ -128,11 +129,11 @@ void Palette::advanceGradient()
{
if (colIndex % 2)
{ // falling curve
- colVal = (int)(255.0 * (cos(M_PI * pos / delay) + 1) / 2);
+ colVal = (int)(255.0 * (cos(PI * pos / delay) + 1) / 2);
}
else
{ // ascending curve
- colVal = (int)(255.0 * (cos(M_PI * (delay - pos) / delay) +
+ colVal = (int)(255.0 * (cos(PI * (delay - pos) / delay) +
1) / 2);
}
@@ -152,7 +153,7 @@ void Palette::advanceGradient()
const gcn::Color &destCol =
RAINBOW_COLORS[(colIndex + 1) % numOfColors];
- startColVal = (cos(M_PI * pos / delay) + 1) / 2;
+ startColVal = (cos(PI * pos / delay) + 1) / 2;
destColVal = 1 - startColVal;
mGradVector[i]->color.r =(int)(startColVal * startCol.r +
diff --git a/src/main.cpp b/src/main.cpp
index 41f1c3d5..08ae4a8c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -173,7 +173,7 @@ static void initInternationalization()
{
#if ENABLE_NLS
#ifdef WIN32
- putenv(("LANG=" + std::string(_nl_locale_name_default())).c_str());
+ SetEnvironmentVariable("LANG", _nl_locale_name_default());
// mingw doesn't like LOCALEDIR to be defined for some reason
bindtextdomain("mana", "translations/");
#else
diff --git a/src/net/manaserv/manaserv_protocol.h b/src/net/manaserv/manaserv_protocol.h
index 2b99bf41..66da57df 100644
--- a/src/net/manaserv/manaserv_protocol.h
+++ b/src/net/manaserv/manaserv_protocol.h
@@ -189,15 +189,13 @@ enum {
PGMSG_PARTY_INVITE = 0x03A0, // S name
GPMSG_PARTY_INVITE_ERROR = 0x03A1, // S name
GCMSG_PARTY_INVITE = 0x03A2, // S inviter, S invitee
- CPMSG_PARTY_INVITE_RESPONSE = 0x03A3, // B error, S name
CPMSG_PARTY_INVITED = 0x03A4, // S name
- PCMSG_PARTY_ACCEPT_INVITE = 0x03A5, // S name
- CPMSG_PARTY_ACCEPT_INVITE_RESPONSE = 0x03A6, // B error, { S name }
- PCMSG_PARTY_REJECT_INVITE = 0x03A7, // S name
- CPMSG_PARTY_REJECTED = 0x03A8, // S name
+ PCMSG_PARTY_INVITE_ANSWER = 0x03A5, // S name, B accept
+ CPMSG_PARTY_INVITE_ANSWER_RESPONSE = 0x03A6, // B error, { S name }
+ CPMSG_PARTY_REJECTED = 0x03A8, // S name, B error
PCMSG_PARTY_QUIT = 0x03AA, // -
CPMSG_PARTY_QUIT_RESPONSE = 0x03AB, // B error
- CPMSG_PARTY_NEW_MEMBER = 0x03B0, // D character id, S name
+ CPMSG_PARTY_NEW_MEMBER = 0x03B0, // S name, S inviter
CPMSG_PARTY_MEMBER_LEFT = 0x03B1, // D character id
// Chat
diff --git a/src/net/manaserv/partyhandler.cpp b/src/net/manaserv/partyhandler.cpp
index 38829507..e1bcb624 100644
--- a/src/net/manaserv/partyhandler.cpp
+++ b/src/net/manaserv/partyhandler.cpp
@@ -51,9 +51,8 @@ PartyHandler::PartyHandler():
{
static const Uint16 _messages[] = {
GPMSG_PARTY_INVITE_ERROR,
- CPMSG_PARTY_INVITE_RESPONSE,
CPMSG_PARTY_INVITED,
- CPMSG_PARTY_ACCEPT_INVITE_RESPONSE,
+ CPMSG_PARTY_INVITE_ANSWER_RESPONSE,
CPMSG_PARTY_QUIT_RESPONSE,
CPMSG_PARTY_NEW_MEMBER,
CPMSG_PARTY_MEMBER_LEFT,
@@ -78,32 +77,35 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
name.c_str()));
} break;
- case CPMSG_PARTY_INVITE_RESPONSE:
- {
- if (msg.readInt8() == ERRMSG_OK)
- {
-
- }
- } break;
-
case CPMSG_PARTY_INVITED:
{
socialWindow->showPartyInvite(msg.readString());
} break;
- case CPMSG_PARTY_ACCEPT_INVITE_RESPONSE:
+ case CPMSG_PARTY_INVITE_ANSWER_RESPONSE:
{
- if (msg.readInt8() == ERRMSG_OK)
+ switch (msg.readInt8())
{
- player_node->setParty(mParty);
- while (msg.getUnreadLength())
- {
- std::string name = msg.readString();
- mParty->addMember(0, name);
- }
+ case ERRMSG_OK:
+ player_node->setParty(mParty);
+ while (msg.getUnreadLength())
+ {
+ std::string name = msg.readString();
+ mParty->addMember(0, name);
+ }
+ break;
+ case ERRMSG_TIME_OUT:
+ SERVER_NOTICE(_("Joining party failed, because the "
+ "invitation has timed out on the server."));
+ break;
+ case ERRMSG_FAILURE:
+ SERVER_NOTICE(_("Joining party failed, because the "
+ "inviter has left the game."));
+ break;
+ default:
+ logger->log("Unknown CPMSG_PARTY_INVITE_ANSWER_RESPONSE.");
+ break;
}
- else
- SERVER_NOTICE(_("Joining party failed."));
} break;
case CPMSG_PARTY_QUIT_RESPONSE:
@@ -117,16 +119,19 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
case CPMSG_PARTY_NEW_MEMBER:
{
- int id = msg.readInt32();
std::string name = msg.readString();
+ std::string inviter = msg.readString();
+ std::string s;
+ if (!inviter.empty())
+ s = strprintf(_(" on invitation from %s"), inviter.c_str());
- SERVER_NOTICE(strprintf(_("%s joined the party."),
- name.c_str()));
+ SERVER_NOTICE(strprintf(_("%s joined the party%s."),
+ name.c_str(), s.c_str()));
if (name == player_node->getName())
player_node->setParty(mParty);
- mParty->addMember(id, name);
+ mParty->addMember(0, name);
} break;
case CPMSG_PARTY_MEMBER_LEFT:
@@ -137,8 +142,25 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
case CPMSG_PARTY_REJECTED:
{
std::string name = msg.readString();
- SERVER_NOTICE(strprintf(
- _("%s rejected your invite."), name.c_str()));
+ switch (msg.readInt8())
+ {
+ case ERRMSG_OK:
+ SERVER_NOTICE(strprintf(_("%s rejected your invite."),
+ name.c_str()));
+ break;
+ case ERRMSG_LIMIT_REACHED:
+ SERVER_NOTICE(_("Party invitation rejected by server, "
+ "because of too many invitations in a "
+ "short time."));
+ break;
+ case ERRMSG_FAILURE:
+ SERVER_NOTICE(strprintf(_("%s is already in a party."),
+ name.c_str()));
+ break;
+ default:
+ logger->log("Unknown CPMSG_PARTY_REJECTED.");
+ break;
+ }
} break;
}
}
@@ -169,10 +191,10 @@ void PartyHandler::invite(const std::string &name)
void PartyHandler::inviteResponse(const std::string &inviter, bool accept)
{
- MessageOut msg = MessageOut(accept ? PCMSG_PARTY_ACCEPT_INVITE :
- PCMSG_PARTY_REJECT_INVITE);
+ MessageOut msg = MessageOut(PCMSG_PARTY_INVITE_ANSWER);
msg.writeString(inviter);
+ msg.writeInt8(accept);
chatServerConnection->send(msg);
}
diff --git a/src/particleemitterprop.h b/src/particleemitterprop.h
index c73d044c..b1268e8d 100644
--- a/src/particleemitterprop.h
+++ b/src/particleemitterprop.h
@@ -21,6 +21,8 @@
#include <cmath>
+static const double PI = 3.14159265;
+
enum ChangeFunc
{
@@ -64,7 +66,7 @@ template <typename T> struct ParticleEmitterProp
switch (changeFunc)
{
case FUNC_SINE:
- val += (T) std::sin(M_PI * 2 * ((double)(tick%changePeriod) / (double)changePeriod)) * changeAmplitude;
+ val += (T) std::sin(PI * 2 * ((double)(tick%changePeriod) / (double)changePeriod)) * changeAmplitude;
break;
case FUNC_SAW:
val += (T) (changeAmplitude * ((double)(tick%changePeriod) / (double)changePeriod)) * 2 - changeAmplitude;
diff --git a/src/party.cpp b/src/party.cpp
index 99295792..e6d9167f 100644
--- a/src/party.cpp
+++ b/src/party.cpp
@@ -22,6 +22,8 @@
#include "actorspritemanager.h"
+#include "net/net.h"
+
PartyMember::PartyMember(Party *party, int id, const std::string &name):
Avatar(name), mId(id), mParty(party), mLeader(false)
{
@@ -44,7 +46,7 @@ Party::~Party()
PartyMember *Party::addMember(int id, const std::string &name)
{
PartyMember *m;
- if ((m = getMember(id)))
+ if (Net::getNetworkType() == ServerInfo::TMWATHENA && (m = getMember(id)))
{
return m;
}
diff --git a/src/utils/specialfolder.cpp b/src/utils/specialfolder.cpp
index 221aeac2..63337578 100644
--- a/src/utils/specialfolder.cpp
+++ b/src/utils/specialfolder.cpp
@@ -39,7 +39,7 @@ std::string getSpecialFolderLocation(int folderId)
std::string ret;
LPITEMIDLIST pItemIdList;
LPMALLOC pMalloc;
- char szPath[_MAX_PATH];
+ char szPath[MAX_PATH];
// get the item ID list for folderId
HRESULT hr = SHGetSpecialFolderLocation(NULL, folderId, &pItemIdList);