Update of /cvsroot/planeshift/planeshift/src/server
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23254/server
Modified Files:
adminmanager.cpp adminmanager.h gem.cpp marriagemanager.cpp
marriagemanager.h psserverchar.cpp psserverchar.h
Log Message:
- Fixed a crash in the sound system, when the sound was fading. It is a temporary
"quick and dirty" fix.
- Added button in the interaction menu for marrying/divorcing from another char.
- Reorganized the code of the marriage manager on the client side.
- Added a function in psServerChar that allows to check if a character has
logon in the latest 2 months.
- Added a GM command for divorcing a character from another one, in the case that
a widow/widower wants to marry another char, or his/her spouse hasn't been online
in the latest 2 months.
- Other several changes in the marriage code.
Index: adminmanager.cpp
===================================================================
RCS file: /cvsroot/planeshift/planeshift/src/server/adminmanager.cpp,v
retrieving revision 1.325
retrieving revision 1.326
diff -C2 -d -r1.325 -r1.326
*** adminmanager.cpp 10 Apr 2006 17:41:36 -0000 1.325
--- adminmanager.cpp 22 Apr 2006 14:01:27 -0000 1.326
***************
*** 28,31 ****
--- 28,32 ----
#include "spawnmanager.h"
#include "chatmanager.h"
+ #include "marriagemanager.h"
#include "gem.h"
#include "clients.h"
***************
*** 501,504 ****
--- 502,509 ----
SetAttrib(me,msg,client);
}
+ else if (msg.command == "/divorce")
+ {
+ Divorce(me, msg, client);
+ }
}
***************
*** 1058,1061 ****
--- 1063,1122 ----
}
+ void AdminManager::Divorce(MsgEntry* me, psAdminCmdMessage& msg, Client *client)
+ {
+ bool onlineDivorcer = false;
+ bool onlineTarget = false;
+
+ if ( !msg.player.Length())
+ {
+ psserver->SendSystemInfo( me->clientnum, "Usage: \"/divorce [character]\"");
+ return;
+ }
+
+ Client* divorcer = clients->Find( msg.player );
+ onlineDivorcer = ( divorcer != NULL );
+ psCharacter* divorcerChar = divorcer->GetCharacterData();
+
+ //If the player that wishes to divorce is not online, we can't proceed.
+ if ( !onlineDivorcer )
+ {
+ psserver->SendSystemInfo( me->clientnum, "The player that wishes to divorce must be online." );
+ return;
+ }
+
+ csString spouseFullName = divorcerChar->GetSpouseName();
+ csString spouseName = spouseFullName.Slice( 0, spouseFullName.FindFirst(' '));
+
+ //If the "spouse" is online, than there is no need to use GM powers for the divorce.
+ Client* target = clients->Find( spouseName );
+ onlineTarget = ( target != NULL );
+
+ if ( onlineTarget )
+ {
+ psserver->SendSystemInfo( me->clientnum, "The two players can agree by themselves on the divorce, since both are online.");
+ return;
+ }
+
+ if ( !psserver->GetCharManager()->HasConnected( spouseName ))//The player was connected recently.
+ {
+ psserver->SendSystemInfo( me->clientnum, "The spouse has been online recently, therefore it is not up to you to divorce the couple.");
+ return;
+ }
+
+ //Now is it time to divorce the player.
+ psMarriageManager* marriageMgr = psserver->GetMarriageManager();
+ if ( !marriageMgr )
+ {
+ psserver->SendSystemError( me->clientnum, "Can't load MarriageManager.");
+ Error1( "MarriageManager failed to load." );
+ return;
+ }
+
+ // Delete entries of character's from DB
+ marriageMgr->DeleteMarriageInfo( divorcerChar );
+ Debug3( LOG_MARRIAGE, "%s divorced from %s.", msg.player.GetData(), spouseName.GetData() );
+
+ }
+
void AdminManager::Teleport(MsgEntry* me, psAdminCmdMessage& msg, Client *client, gemObject* subject)
{
Index: adminmanager.h
===================================================================
RCS file: /cvsroot/planeshift/planeshift/src/server/adminmanager.h,v
retrieving revision 1.84
retrieving revision 1.85
diff -C2 -d -r1.84 -r1.85
*** adminmanager.h 16 Mar 2006 04:48:21 -0000 1.84
--- adminmanager.h 22 Apr 2006 14:01:28 -0000 1.85
***************
*** 158,161 ****
--- 158,164 ----
void SetAttrib(MsgEntry* me, psAdminCmdMessage& msg, Client *client);
+ //Divorce char1 and char2, if char2 hasn't been online in the latest 2 months, or is deleted.
+ void Divorce( MsgEntry* me, psAdminCmdMessage& msg, Client *client );
+
/// Handles a user submitting a petition
void HandleAddPetition(MsgEntry* me, psAdminCmdMessage& msg,Client *client);
Index: gem.cpp
===================================================================
RCS file: /cvsroot/planeshift/planeshift/src/server/gem.cpp,v
retrieving revision 1.344
retrieving revision 1.345
diff -C2 -d -r1.344 -r1.345
*** gem.cpp 17 Apr 2006 20:03:25 -0000 1.344
--- gem.cpp 22 Apr 2006 14:01:28 -0000 1.345
***************
*** 2785,2788 ****
--- 2785,2799 ----
options |= psGUIInteractMessage::ATTACK;
}
+ //Options for a wedding or a divorce, in order to show the proper button.
+ //If the character is married, the only option is to divorce.
+ if (GetCharacterData()->GetIsMarried())
+ {
+ options |= psGUIInteractMessage::DIVORCE;
+ }
+ //If the target is not married, then we can ask to marry him/her. Otherwise, no other option is valid.
+ else if (!target->GetCharacterData()->GetIsMarried())
+ {
+ options |= psGUIInteractMessage::MARRIAGE;
+ }
if (!options)
Index: marriagemanager.cpp
===================================================================
RCS file: /cvsroot/planeshift/planeshift/src/server/marriagemanager.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** marriagemanager.cpp 15 Apr 2006 08:31:01 -0000 1.16
--- marriagemanager.cpp 22 Apr 2006 14:01:28 -0000 1.17
***************
*** 178,182 ****
psserver->SendSystemResult( divorcedClient->GetClientNum(), "You are now divorced.");
- // Try to find the divorced client
Debug3( LOG_MARRIAGE, "%s divorced from %s.", divorcerFirstName.GetData(), divorcedFirstName.GetData() );
--- 178,181 ----
***************
*** 188,194 ****
clientConSet = clients;
psserver->GetEventManager()->Subscribe(this, MSGTYPE_MARRIAGE_PROPOSE );
psserver->GetEventManager()->Subscribe(this, MSGTYPE_MARRIAGE_DIVORCE );
! psserver->GetEventManager()->Subscribe(this, MSGTYPE_MARRIAGE_DETAILS );
}
--- 187,195 ----
clientConSet = clients;
+ divorceMsg = "";
+
psserver->GetEventManager()->Subscribe(this, MSGTYPE_MARRIAGE_PROPOSE );
psserver->GetEventManager()->Subscribe(this, MSGTYPE_MARRIAGE_DIVORCE );
! psserver->GetEventManager()->Subscribe(this, MSGTYPE_MARRIAGE_DIVORCE_CONFIRM );
}
***************
*** 197,201 ****
psserver->GetEventManager()->Unsubscribe(this, MSGTYPE_MARRIAGE_PROPOSE );
psserver->GetEventManager()->Unsubscribe(this, MSGTYPE_MARRIAGE_DIVORCE );
! psserver->GetEventManager()->Unsubscribe(this, MSGTYPE_MARRIAGE_DETAILS );
}
--- 198,202 ----
psserver->GetEventManager()->Unsubscribe(this, MSGTYPE_MARRIAGE_PROPOSE );
psserver->GetEventManager()->Unsubscribe(this, MSGTYPE_MARRIAGE_DIVORCE );
! psserver->GetEventManager()->Unsubscribe(this, MSGTYPE_MARRIAGE_DIVORCE_CONFIRM );
}
***************
*** 307,317 ****
if ( !client->GetCharacterData()->GetIsMarried() )
{
! psserver->SendSystemError( me->clientnum, "Only married people can divorce." );
break;
}
!
csString divorcerName = client->GetCharacterData()->GetCharName();
! csString divorceMsg = me->GetStr();
!
psString divorcedCharFirstName;
psString divorcedChar = client->GetCharacterData()->GetSpouseName();
--- 308,324 ----
if ( !client->GetCharacterData()->GetIsMarried() )
{
! psserver->SendSystemError( me->clientnum, "Before divorcing, you should get married." );
break;
}
! divorceMsg = me->GetStr();
! psMarriageMsgDivorceConfirm me;
! me.SendMessage( );
! break;
! }
! case MSGTYPE_MARRIAGE_DIVORCE_CONFIRM:
! {
! //We are sure 200% that we are gonna divorce.
csString divorcerName = client->GetCharacterData()->GetCharName();
!
psString divorcedCharFirstName;
psString divorcedChar = client->GetCharacterData()->GetSpouseName();
***************
*** 342,366 ****
}
else
! {
! psserver->SendSystemInfo( me->clientnum, "%s is not in Yliakum right now.", divorcedChar.GetData());
}
break;
}
! /* // Some client requested marriage related details of a char
! case MSGTYPE_MARRIAGE_DETAILS:
! {
! const char* charName = me->GetStr();
! const char* spousename = client->GetCharacterData()->GetSpouseName();
!
! // No spouse name? replace it with "none"
! if ( !strcmp( spousename, "" ) )
! spousename = "none";
!
! // Send spouse name
! psMarriageMsgDetails detailsMsg( charName, spousename, client->GetClientNum() );
! detailsMsg.SendMessage();
break;
- }*/
} // switch( )
--- 349,391 ----
}
else
! {
! int result;
! result = psserver->GetCharManager()->HasConnected( divorcedCharFirstName );
! //The partner doesn't exist.
! if ( result == 1 )
! {
! //If female
! if ( client->GetCharacterData()->GetRaceInfo()->gender == 1 )
! {
! psserver->SendSystemError( me->clientnum,"%s is probably dead and you are a widow!",
! divorcedCharFirstName.GetData() );
! }
! //If male or Kran
! else
! {
! psserver->SendSystemError( me->clientnum,"%s is probably dead and you are a widower!",
! divorcedCharFirstName.GetData() );
! }
! psserver->SendSystemInfo( me->clientnum, "You can divorce anyway, but you have to contact a Game Master." );
!
! }
! else if ( result == 2 )
! {
! //The partner hasn't logon in the latest two months.
! psserver->SendSystemInfo( me->clientnum, "%s hasn't walked in Yliakum in a long time.", divorcedChar.GetData());
! psserver->SendSystemInfo( me->clientnum, "Contact a Game Master for obtaining a divorce.");
! }
! else
! {
! //If we are here, the partner char is still existing and it has been connecting recently. Wait to be online.
! psserver->SendSystemInfo( me->clientnum, "%s is not in Yliakum right now.", divorcedChar.GetData());
! }
}
break;
}
!
! default:
break;
} // switch( )
Index: marriagemanager.h
===================================================================
RCS file: /cvsroot/planeshift/planeshift/src/server/marriagemanager.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** marriagemanager.h 15 Apr 2006 01:20:25 -0000 1.8
--- marriagemanager.h 22 Apr 2006 14:01:28 -0000 1.9
***************
*** 51,54 ****
--- 51,57 ----
ClientConnectionSet* clientConSet;
+ ///Used for storing the divorce message.
+ csString divorceMsg;
+
/** Creates a character's entry in "character_marriage_details"
table of DB if one is not present already. */
Index: psserverchar.cpp
===================================================================
RCS file: /cvsroot/planeshift/planeshift/src/server/psserverchar.cpp,v
retrieving revision 1.367
retrieving revision 1.368
diff -C2 -d -r1.367 -r1.368
*** psserverchar.cpp 18 Apr 2006 01:14:45 -0000 1.367
--- psserverchar.cpp 22 Apr 2006 14:01:28 -0000 1.368
***************
*** 68,71 ****
--- 68,74 ----
#include "serverstatus.h"
+ ///This expresses in seconds how many days the char hasn't logon. 60 days, at the moment.
+ #define MAX_DAYS_NO_LOGON 5184000
+
psServerCharManager::psServerCharManager()
{
***************
*** 389,392 ****
--- 392,419 ----
}
+
+ int psServerCharManager::HasConnected( csString name )
+ {
+ int secondsLastLogin;
+ secondsLastLogin = 0;
+
+ //Query to the db that calculates already the amount of seconds since the last login.
+ Result result(db->Select("SELECT last_login, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_login) as seconds_since_last_login FROM characters WHERE name = '%s'", name.GetData() ));
+ //There is no character with such a name.
+ if (!result.IsValid() || result.Count() == 0)
+ {
+ return 1;
+ }
+ //We check when the char was last online.
+ secondsLastLogin = result[0].GetInt(1);
+
+ if ( secondsLastLogin > MAX_DAYS_NO_LOGON )//the result is major than 2 month
+ {
+ return 2;
+ }
+
+ //The char has connected recently.
+ return 0;
+ }
void psServerCharManager::HandleCraftInfo( MsgEntry* me, Client* client )
{
Index: psserverchar.h
===================================================================
RCS file: /cvsroot/planeshift/planeshift/src/server/psserverchar.h,v
retrieving revision 1.67
retrieving revision 1.68
diff -C2 -d -r1.67 -r1.68
*** psserverchar.h 18 Apr 2006 01:14:45 -0000 1.67
--- psserverchar.h 22 Apr 2006 14:01:28 -0000 1.68
***************
*** 216,219 ****
--- 216,222 ----
bool IsBanned(const char* name);
+
+ ///Checked if the character exists still or if it hasn't connected in two months.
+ int HasConnected( csString name );
protected:
|