From: Anders R. <ma...@us...> - 2005-11-27 15:09:16
|
Update of /cvsroot/planeshift/planeshift/src/server/bulkobjects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14773/src/server/bulkobjects Modified Files: dictionary.cpp dictionary.h pscharacter.cpp pscharacter.h psnpcdialog.cpp Log Message: - Updated all CVS quests to use new quest system - Changed the pron scripts from 26 to use { instead of [, updated examples. - Moved restaring of search for responses with no prior response out of FindResposne so that both cases would do all the same processing and serching for quests. This prevent some quest steps from deadlock when a response was checked for another quest than the actual quest. - Renamed completiondate to lockout_end, and changed db entry to state remaininglockout, to bether mach the use of the variables. Index: dictionary.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/dictionary.cpp,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** dictionary.cpp 26 Nov 2005 11:35:36 -0000 1.80 --- dictionary.cpp 27 Nov 2005 15:09:05 -0000 1.81 *************** *** 276,288 **** Debug1(LOG_STARTUP,"Loading Triggers...\n"); ! Result result(db->Select("select id," ! " area," ! " trigger," ! " prior_response_required," ! " min_attitude_required," ! " max_attitude_required," ! " response_id," ! " quest_id" ! " from npc_triggers") ); if (!result.IsValid()) --- 276,280 ---- Debug1(LOG_STARTUP,"Loading Triggers...\n"); ! Result result(db->Select("select * from npc_triggers") ); if (!result.IsValid()) *************** *** 313,329 **** bool NPCDialogDict::LoadResponses(iDataConnection *db) { ! Result result(db->Select("select id," ! " response1," ! " response2," ! " response3," ! " response4," ! " response5, " ! " script, " ! " pronoun_him," ! " pronoun_her," ! " pronoun_it," ! " pronoun_them," ! " quest_id" ! " from npc_responses")); if (!result.IsValid()) --- 305,309 ---- bool NPCDialogDict::LoadResponses(iDataConnection *db) { ! Result result(db->Select("SELECT * FROM npc_responses")); if (!result.IsValid()) *************** *** 371,391 **** } - /*bool NPCDialogDict::IsValidWord(csString& word) - { - word.Downcase(); - NPCDialogWord key; - key.word = word; - - NPCDialogWord *db = words.Find(&key); - - if (!db) - return false; - - if (db->synonym.Length()) // this silently substitutes synonyms if any - word = db->synonym; - - return true; - }*/ - NpcResponse *NPCDialogDict::FindResponse(gemNPC * npc, const char *area, --- 351,354 ---- *************** *** 403,424 **** key.trigger = trigger; key.priorresponseID = priorresponse; ! key.max_attitude = faction; ! key.min_attitude = faction; trig = triggers.Find(&key); - // If not found check for no precondition. Both 0 and -1 can be - // used for no precodition in DB so check both. - if (!trig) - { - key.priorresponseID = 0; // check for no precondition also - trig = triggers.Find(&key); - if (!trig) - { - key.priorresponseID = -1; // check for no precondition also - trig = triggers.Find(&key); - } - } - if (trig) { --- 366,374 ---- key.trigger = trigger; key.priorresponseID = priorresponse; ! key.max_attitude = faction; ! key.min_attitude = faction; trig = triggers.Find(&key); if (trig) { *************** *** 577,581 **** } ! bool NPCDialogDict::AddTrigger(const char *k_area,const char *mytrigger,int prior_response, int trigger_response, int quest_id) { NpcTrigger *trig; --- 527,531 ---- } ! bool NPCDialogDict::AddTrigger(const char *k_area,const char *mytrigger,int prior_response, int trigger_response) { NpcTrigger *trig; *************** *** 613,617 **** newtrig->min_attitude = -100; newtrig->max_attitude = 100; - newtrig->questID = quest_id; newtrig->responseIDlist.Push(trigger_response); --- 563,566 ---- *************** *** 633,639 **** for (trig = trig_iter.First(); trig; trig = ++trig_iter) { ! CPrintf(CON_CMDOUTPUT ,"%8d %20s %-60.60s %8d %4d %4d %7d", ! trig->id,trig->area.GetData(),trig->trigger.GetData(),trig->priorresponseID, ! trig->min_attitude, trig->max_attitude, trig->questID); for (size_t i = 0; i < trig->responseIDlist.Length(); i++) { --- 582,591 ---- for (trig = trig_iter.First(); trig; trig = ++trig_iter) { ! csString trigger; ! trigger.Format("\"%s\"",trig->trigger.GetDataSafe()); ! ! CPrintf(CON_CMDOUTPUT ,"%8d %20s %-60.60s %8d %4d %4d", // %7d", ! trig->id,trig->area.GetData(),trigger.GetData(),trig->priorresponseID, ! trig->min_attitude, trig->max_attitude); for (size_t i = 0; i < trig->responseIDlist.Length(); i++) { *************** *** 688,692 **** min_attitude = row.GetInt("min_attitude_required"); max_attitude = row.GetInt("max_attitude_required"); - questID = row.GetInt("quest_id"); responseIDlist.Push(row.GetInt("response_id")); --- 640,643 ---- *************** *** 696,715 **** bool NpcTrigger::HaveAvailableResponses(Client * client, gemNPC * npc, NPCDialogDict * dict, csArray<int> *availableResponseList) { - // The first check have to go. If multiple quests use the same trigger this - // will block the second quest. - - // check if trigger is associated to a quest and quest is currently locked - if (questID > 0) - { - psQuest *quest = psServer::cachemanager.GetQuestByID(questID); - bool avail = client->GetCharacterData()->CheckQuestAvailable(quest,npc->GetPlayerID() ); - if (!avail) - { - CPrintf(CON_DEBUG, "NPCDialogDict::HaveAvailableResponses trigger %s not available because " - "quest %s isn't available\n",trigger.GetDataSafe(),quest->GetName()); - return false; - } - } - bool haveAvail = false; --- 647,650 ---- Index: dictionary.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/dictionary.h,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** dictionary.h 24 Nov 2005 23:24:05 -0000 1.43 --- dictionary.h 27 Nov 2005 15:09:06 -0000 1.44 *************** *** 111,116 **** const char *mytrigger, int prior_response, ! int trigger_response, ! int quest_id); /** --- 111,115 ---- const char *mytrigger, int prior_response, ! int trigger_response); /** *************** *** 174,178 **** int max_attitude; csArray<int> responseIDlist; ! int questID; /// Load the trigger from a database --- 173,177 ---- int max_attitude; csArray<int> responseIDlist; ! // int questID; /// Load the trigger from a database Index: pscharacter.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/pscharacter.cpp,v retrieving revision 1.299 retrieving revision 1.300 diff -C2 -d -r1.299 -r1.300 *** pscharacter.cpp 27 Nov 2005 14:27:41 -0000 1.299 --- pscharacter.cpp 27 Nov 2005 15:09:06 -0000 1.300 *************** *** 1246,1250 **** // This data is loaded only if it's a player, not an NPC if ( !IsNPC() ) ! { if (!LoadQuestAssignments()) { --- 1246,1250 ---- // This data is loaded only if it's a player, not an NPC if ( !IsNPC() ) ! { if (!LoadQuestAssignments()) { *************** *** 2840,2844 **** q->dirty = true; q->status = PSQUEST_ASSIGNED; ! q->completiondate = 0; q->assigner_id = assigner_id; --- 2840,2844 ---- q->dirty = true; q->status = PSQUEST_ASSIGNED; ! q->lockout_end = 0; q->assigner_id = assigner_id; *************** *** 2900,2904 **** q->dirty = true; q->status = PSQUEST_COMPLETE; // completed ! q->completiondate = csGetTicks() + q->quest->GetPlayerLockoutTime(); Debug3(LOG_QUESTS, "Player '%s' just completed quest '%s'.\n",GetCharName(),quest->GetName() ); --- 2900,2904 ---- q->dirty = true; q->status = PSQUEST_COMPLETE; // completed ! q->lockout_end = csGetTicks() + q->quest->GetPlayerLockoutTime(); Debug3(LOG_QUESTS, "Player '%s' just completed quest '%s'.\n",GetCharName(),quest->GetName() ); *************** *** 2918,2922 **** q->dirty = true; q->status = PSQUEST_DELETE; // discarded ! q->completiondate = csGetTicks() + q->quest->GetPlayerLockoutTime(); // assignment entry will be deleted after expiration Debug3(LOG_QUESTS, "Player '%s' just discarded quest '%s'.\n",GetCharName(),q->quest->GetName() ); --- 2918,2922 ---- q->dirty = true; q->status = PSQUEST_DELETE; // discarded ! q->lockout_end = csGetTicks() + q->quest->GetPlayerLockoutTime(); // assignment entry will be deleted after expiration Debug3(LOG_QUESTS, "Player '%s' just discarded quest '%s'.\n",GetCharName(),q->quest->GetName() ); *************** *** 2990,2994 **** { // Still in lockout ! if (assigned_quests[i]->completiondate > now) { if(GetActor()->GetSecurityLevel() > 21) --- 2990,2994 ---- { // Still in lockout ! if (assigned_quests[i]->lockout_end > now) { if(GetActor()->GetSecurityLevel() > 21) *************** *** 2997,3006 **** { psserver->SendSystemInfo(GetActor()->GetClientID(), ! "GM NOTICE: Quest found; player lockout time has been overrided"); return true; // Quest is available for GM } else psserver->SendSystemInfo(GetActor()->GetClientID(), ! "GM NOTICE: Quest found, but player lockout time hasn't elapsed yet"); } --- 2997,3008 ---- { psserver->SendSystemInfo(GetActor()->GetClientID(), ! "GM NOTICE: Quest(%s) found; player lockout time has been overrided", ! quest->GetName()); return true; // Quest is available for GM } else psserver->SendSystemInfo(GetActor()->GetClientID(), ! "GM NOTICE: Quest(%s) found, but player lockout time hasn't elapsed yet", ! quest->GetName()); } *************** *** 3021,3030 **** { psserver->SendSystemInfo(GetActor()->GetClientID(), ! "GM NOTICE: Quest found; quest lockout time has been overrided"); return true; // Quest is available for GM } else psserver->SendSystemInfo(GetActor()->GetClientID(), ! "GM NOTICE: Quest found, but quest lockout time hasn't elapsed yet"); } --- 3023,3034 ---- { psserver->SendSystemInfo(GetActor()->GetClientID(), ! "GM NOTICE: Quest(%s) found; quest lockout time has been overrided", ! quest->GetName()); return true; // Quest is available for GM } else psserver->SendSystemInfo(GetActor()->GetClientID(), ! "GM NOTICE: Quest(%s) found, but quest lockout time hasn't elapsed yet", ! quest->GetName()); } *************** *** 3039,3043 **** CS_ASSERT( quest ); // Must not be NULL ! return quest->CheckPrerequisite(this); } --- 3043,3067 ---- CS_ASSERT( quest ); // Must not be NULL ! if (!quest->CheckPrerequisite(this)) ! { ! if(GetActor()->GetSecurityLevel() > 21) ! { ! if (GetActor()->questtester) // GM flag ! { ! psserver->SendSystemInfo(GetActor()->GetClientID(), ! "GM NOTICE: Quest found(%s); quest prerequisite has been overrided", ! quest->GetName()); ! return true; // Quest is available for GM ! } ! else ! { ! psserver->SendSystemInfo(GetActor()->GetClientID(), ! "GM NOTICE: Quest(%s) found, but quest prerequisite isn't fulfitted", ! quest->GetName()); ! } ! } ! return false; // Cannot start this quest without all the prerequisites ! } ! return true; // All Quest prerequiste are ok } *************** *** 3070,3075 **** // will delete the quest only after the expiration time, so the player cannot get it again immediately if (q->status == PSQUEST_DELETE && ! (!q->quest->GetPlayerLockoutTime() || !q->completiondate || ! (q->completiondate < now))) // delete { r = db->Command("delete from character_quests" --- 3094,3099 ---- // will delete the quest only after the expiration time, so the player cannot get it again immediately if (q->status == PSQUEST_DELETE && ! (!q->quest->GetPlayerLockoutTime() || !q->lockout_end || ! (q->lockout_end < now))) // delete { r = db->Command("delete from character_quests" *************** *** 3089,3098 **** // at load from DB. csTicks remaining_time = 0; ! if (q->completiondate && q->completiondate > now) ! remaining_time = q->completiondate - now; r = db->Command("update character_quests " "set status='%c'," ! "completiondate=%ld " " where player_id=%d" " and quest_id=%d", --- 3113,3122 ---- // at load from DB. csTicks remaining_time = 0; ! if (q->lockout_end && q->lockout_end > now) ! remaining_time = q->lockout_end - now; r = db->Command("update character_quests " "set status='%c'," ! "remaininglockout=%ld " " where player_id=%d" " and quest_id=%d", *************** *** 3104,3108 **** { r = db->Command("insert into character_quests" ! "(player_id, assigner_id, quest_id, status, completiondate) " "values (%d, %d, %d, '%c', %d)", characterid, --- 3128,3132 ---- { r = db->Command("insert into character_quests" ! "(player_id, assigner_id, quest_id, status, remaininglockout) " "values (%d, %d, %d, '%c', %d)", characterid, *************** *** 3133,3158 **** bool psCharacter::LoadMarriageInfo() { ! Result result( db->Select("SELECT * FROM character_marriage_details" ! " WHERE character_id=%d", characterid)); ! if ( !result.IsValid() ) { Error3("Could not load marriage info for character %d. Error was: %s", characterid, db->GetLastError() ); return false; } ! else if ( result.Count() == 0 ) ! { ! return true; ! } ! ! const char* spouseName = result[0]["spousename"]; ! if ( spouseName == NULL ) ! return true; SetSpouseName( spouseName ); ! SetIsMarried( true ); ! ! Notify2( LOG_MARRIAGE, "Successfully loaded marriage info for %s", name.GetData() ); ! ! return true; } --- 3157,3182 ---- bool psCharacter::LoadMarriageInfo() { ! Result result( db->Select("SELECT * FROM character_marriage_details" ! " WHERE character_id=%d", characterid)); ! if ( !result.IsValid() ) { Error3("Could not load marriage info for character %d. Error was: %s", characterid, db->GetLastError() ); return false; } ! else if ( result.Count() == 0 ) ! { ! return true; ! } + const char* spouseName = result[0]["spousename"]; + if ( spouseName == NULL ) + return true; + SetSpouseName( spouseName ); ! SetIsMarried( true ); ! ! Notify2( LOG_MARRIAGE, "Successfully loaded marriage info for %s", name.GetData() ); ! ! return true; } *************** *** 3175,3179 **** q->quest = psServer::cachemanager.GetQuestByID( result[i].GetInt("quest_id") ); q->status = result[i]["status"][0]; ! q->completiondate = now + result[i].GetInt("completiondate"); q->assigner_id = result[i].GetInt("assigner_id"); --- 3199,3203 ---- q->quest = psServer::cachemanager.GetQuestByID( result[i].GetInt("quest_id") ); q->status = result[i]["status"][0]; ! q->lockout_end = now + result[i].GetInt("remaininglockout"); q->assigner_id = result[i].GetInt("assigner_id"); *************** *** 3187,3194 **** // Sanity check to see if time for completion is withing // lockout time. ! if (q->completiondate > now + q->quest->GetPlayerLockoutTime()) ! q->completiondate = now + q->quest->GetPlayerLockoutTime(); ! Debug4(LOG_QUESTS, "Loaded quest %d, status %c, for player %d.\n",q->quest->GetID(),q->status, characterid); assigned_quests.Push(q); } --- 3211,3220 ---- // Sanity check to see if time for completion is withing // lockout time. ! if (q->lockout_end > now + q->quest->GetPlayerLockoutTime()) ! q->lockout_end = now + q->quest->GetPlayerLockoutTime(); ! Debug5(LOG_QUESTS, "Loaded quest %-40.40s, status %c, lockout %d, for player %s.\n", ! q->quest->GetName(),q->status, ! ( q->lockout_end > now ? q->lockout_end-now:0),GetCharFullName()); assigned_quests.Push(q); } Index: pscharacter.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/pscharacter.h,v retrieving revision 1.159 retrieving revision 1.160 diff -C2 -d -r1.159 -r1.160 *** pscharacter.h 26 Nov 2005 11:35:36 -0000 1.159 --- pscharacter.h 27 Nov 2005 15:09:06 -0000 1.160 *************** *** 187,192 **** /// Dirty flag determines minimal save on exit bool dirty; ! /// When a quest is completed, often it cannot immediately be repeated. This sets that timer. ! unsigned long completiondate; }; --- 187,192 ---- /// Dirty flag determines minimal save on exit bool dirty; ! /// When a quest is completed, often it cannot immediately be repeated. This indicate the time when it can be started again. ! unsigned long lockout_end; }; *************** *** 898,921 **** int GetAccount() { return accountid; } ! void SetName(const char* newName); ! void SetLastName(const char* newLastName); void SetFullName(const char* newFirstName, const char* newLastName); ! const char *GetCharName() { return name.GetData(); } ! const char *GetCharLastName() { return lastname.GetData(); } ! const char *GetCharFullName() { return fullname.GetData(); } ! ! int GetCharType() { return characterType; } ! void SetCharType( int v ) { characterType = (v < PSCHARACTER_TYPE_COUNT )? v : PSCHARACTER_TYPE_PLAYER; } ! const char *GetCharTypeName() { return psCharacter::characterTypeName[ characterType ]; } ! ! void SetSpouseName(const char* name); ! /** Gets Spouse Name of a character. ! * @return SpouseName or "" if not married. ! */ ! const char *GetSpouseName() { return spouseName.GetData(); } ! void SetIsMarried( bool married ) { isMarried = married; } ! bool GetIsMarried() { return isMarried; } void SetRaceInfo(psRaceInfo *rinfo); psRaceInfo *GetRaceInfo(); --- 898,921 ---- int GetAccount() { return accountid; } ! void SetName(const char* newName); ! void SetLastName(const char* newLastName); void SetFullName(const char* newFirstName, const char* newLastName); ! const char *GetCharName() { return name.GetData(); } ! const char *GetCharLastName() { return lastname.GetData(); } ! const char *GetCharFullName() { return fullname.GetData(); } ! ! int GetCharType() { return characterType; } ! void SetCharType( int v ) { characterType = (v < PSCHARACTER_TYPE_COUNT )? v : PSCHARACTER_TYPE_PLAYER; } ! const char *GetCharTypeName() { return psCharacter::characterTypeName[ characterType ]; } + void SetSpouseName(const char* name); + /** Gets Spouse Name of a character. + * @return SpouseName or "" if not married. + */ + const char *GetSpouseName() { return spouseName.GetData(); } + void SetIsMarried( bool married ) { isMarried = married; } + bool GetIsMarried() { return isMarried; } + void SetRaceInfo(psRaceInfo *rinfo); psRaceInfo *GetRaceInfo(); *************** *** 1057,1069 **** void RecalculateStats(); ! bool IsNPC() { return npc_masterid != 0; }; ! /// Used to determine if this NPC is a pet ! bool IsPet() { return characterType == 2; }; ! int GetFamiliarID() { return familiar_id; }; ! void SetFamiliarID(int v) { familiar_id = v; }; ! const char *GetAnimalAffinity() { return animal_affinity.GetData(); }; ! void SetAnimialAffinity( const char* v ) { animal_affinity = v; }; ! int GetOwnerID() { return owner_id; }; ! void SetOwnerID(int v) { owner_id = v; }; bool UpdateStatDRData(csTicks now); --- 1057,1069 ---- void RecalculateStats(); ! bool IsNPC() { return npc_masterid != 0; }; ! /// Used to determine if this NPC is a pet ! bool IsPet() { return characterType == 2; }; ! int GetFamiliarID() { return familiar_id; }; ! void SetFamiliarID(int v) { familiar_id = v; }; ! const char *GetAnimalAffinity() { return animal_affinity.GetData(); }; ! void SetAnimialAffinity( const char* v ) { animal_affinity = v; }; ! int GetOwnerID() { return owner_id; }; ! void SetOwnerID(int v) { owner_id = v; }; bool UpdateStatDRData(csTicks now); *************** *** 1237,1242 **** psWorkGameEvent * workEvent; ! //Player description ! csString description; /// Kill Exp --- 1237,1242 ---- psWorkGameEvent * workEvent; ! //Player description ! csString description; /// Kill Exp Index: psnpcdialog.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/psnpcdialog.cpp,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** psnpcdialog.cpp 21 Nov 2005 07:37:47 -0000 1.61 --- psnpcdialog.cpp 27 Nov 2005 15:09:06 -0000 1.62 *************** *** 342,345 **** --- 342,350 ---- resp = dict->FindResponse(self, area->area,trigger,0,currentClient->GetLastResponse(),currentClient); + if (!resp) // If no respons found try search without last resposne + { + resp = dict->FindResponse(self, area->area,trigger,0,-1,currentClient); + } + if (resp) *************** *** 459,470 **** currentClient = client; CleanPunctuation(pstext); if (!CheckPronouns(pstext)) { ! CPrintf(CON_DEBUG, "Faild pronouns check\n"); return ErrorResponse(pstext); } ! FilterKnownTerms(pstext, trigger); if (trigger.TermLength() == 0) { --- 464,484 ---- currentClient = client; + // Removes everything except alphanumeric character and spaces + // Removes the NPC name CleanPunctuation(pstext); + + // Replace him/he,her/she,them/they,it with the stored + // antecedent if (!CheckPronouns(pstext)) { ! CPrintf(CON_DEBUG, "Faild pronouns check for \"%s\"\n",pstext.GetDataSafe()); return ErrorResponse(pstext); } ! ! // Replace known terms to get standard terms ! // eg. hello is replaced with gretting FilterKnownTerms(pstext, trigger); + + if (trigger.TermLength() == 0) { |