From: Luca P. <lpa...@us...> - 2003-03-26 16:37:29
|
Update of /cvsroot/planeshift/planeshift/src/common/psprop/npc In directory sc8-pr-cvs1:/tmp/cvs-serv14060 Modified Files: dictionary.cpp psnpcdialog.cpp psnpcdialog.h Log Message: fixed lastresponse. it was not committed to this branch. Index: dictionary.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/psprop/npc/dictionary.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** dictionary.cpp 17 Mar 2003 08:50:39 -0000 1.13 --- dictionary.cpp 26 Mar 2003 16:37:13 -0000 1.14 *************** *** 233,250 **** bool error = false; - printf("Test 1.\n"); if (!trig) // if still not found { key.trigger.Append(" error"); - printf("Test 2.\n"); trig = triggers.Find(&key); error = true; if (!trig) { - printf("Test 3.\n"); return NULL; } } ! printf("Test 4 %s.\n", (const char*)trig->trigger); NPCDialogResponse *resp; --- 233,247 ---- bool error = false; if (!trig) // if still not found { key.trigger.Append(" error"); trig = triggers.Find(&key); error = true; if (!trig) { return NULL; } } ! printf("NPCDialogDict::FindResponse trigger: %s.\n", (const char*)trig->trigger); NPCDialogResponse *resp; Index: psnpcdialog.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/psprop/npc/psnpcdialog.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** psnpcdialog.cpp 25 Mar 2003 22:58:46 -0000 1.28 --- psnpcdialog.cpp 26 Mar 2003 16:37:14 -0000 1.29 *************** *** 348,355 **** ! void celPcNPCDialog::FindResponse(csString& trigger,const char *text) { BinaryTreeIterator<KnowledgeArea> loop(&knowareas); KnowledgeArea *area; for (area = loop.First(); area; area = ++loop) --- 348,356 ---- ! NPCDialogResponse *celPcNPCDialog::FindResponse(csString& trigger,const char *text) { BinaryTreeIterator<KnowledgeArea> loop(&knowareas); KnowledgeArea *area; + NPCDialogResponse *resp; for (area = loop.First(); area; area = ++loop) *************** *** 357,361 **** printf("NPC checking %s for trigger %s , with last_response %d...\n",(const char *)area->area,(const char *)trigger, last_response_id); trigger.strlwr(); ! NPCDialogResponse *resp = dict->FindResponse(area->area,trigger,0,last_response_id); if (resp) --- 358,362 ---- printf("NPC checking %s for trigger %s , with last_response %d...\n",(const char *)area->area,(const char *)trigger, last_response_id); trigger.strlwr(); ! resp = dict->FindResponse(area->area,trigger,0,last_response_id); if (resp) *************** *** 391,394 **** --- 392,397 ---- if (!lastresponse.Length()) AddBadText(text); + + return resp; } *************** *** 439,442 **** --- 442,446 ---- { csString trigger; + NPCDialogResponse *resp; currentplayer = player; *************** *** 444,466 **** FindTriggerWords(text,trigger); if (trigger.Length()) { ! FindResponse(trigger,text); if (lastresponse.Length() == 0) { ! trigger = "error"; ! FindResponse(trigger,text); } } else { AddBadText(text); ! ! trigger = "error"; ! FindResponse(trigger,text); } ! if (lastresponse.Length() == 0) ! lastresponse = "I didn't understand what you said."; SubstituteKeywords(); --- 448,479 ---- FindTriggerWords(text,trigger); + bool error = 0; if (trigger.Length()) { ! resp = FindResponse(trigger,text); if (lastresponse.Length() == 0) { ! error = 1; ! trigger = "error"; ! resp = FindResponse(trigger,text); } } else { + error = 1; AddBadText(text); ! ! trigger = "error"; ! resp = FindResponse(trigger,text); } ! if (lastresponse.Length() == 0) { ! error = 1; ! lastresponse = "I didn't understand what you said."; ! } ! ! // update the previous response id only if no errors ! if (error==0) ! last_response_id = resp->id; SubstituteKeywords(); *************** *** 486,491 **** antecedent_them = resp->them; ! if (resp->type == NPCDialogResponse::VALID_RESPONSE) ! last_response_id = resp->id; } --- 499,504 ---- antecedent_them = resp->them; ! //if (resp->type == NPCDialogResponse::VALID_RESPONSE) ! // last_response_id = resp->id; } Index: psnpcdialog.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/psprop/npc/psnpcdialog.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** psnpcdialog.h 13 Mar 2003 23:25:00 -0000 1.10 --- psnpcdialog.h 26 Mar 2003 16:37:16 -0000 1.11 *************** *** 84,88 **** void FindTriggerWords(const char *text,csString& trigger); ! void FindResponse(csString& trigger,const char *text); bool CheckPronouns(xmlString& text); void UpdateAntecedents(NPCDialogResponse *resp); --- 84,88 ---- void FindTriggerWords(const char *text,csString& trigger); ! NPCDialogResponse* FindResponse(csString& trigger,const char *text); bool CheckPronouns(xmlString& text); void UpdateAntecedents(NPCDialogResponse *resp); |