From: Dave B. <mr...@us...> - 2007-09-05 21:27:58
|
Update of /cvsroot/planeshift/planeshift/src/server/bulkobjects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15992 Modified Files: psitemstats.h psitemstats.cpp Log Message: Book title & authorship changes Index: psitemstats.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/psitemstats.h,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** psitemstats.h 8 Aug 2007 14:33:55 -0000 1.74 --- psitemstats.h 5 Sep 2007 21:27:59 -0000 1.75 *************** *** 114,117 **** --- 114,124 ---- }; + enum PSITEMSTATS_CREATORSTATUS + { + PSITEMSTATS_CREATOR_VALID = 0, + PSITEMSTATS_CREATOR_UNASSIGNED, // books writ before creator stat + PSITEMSTATS_CREATOR_UNKNOWN // e.g. creator player deleted + }; + /******************************************************/ /* Slots are treated as boolean flag-like values here */ *************** *** 313,316 **** --- 320,326 ---- psXMLString creativeDefinitionXML; csString content; + + unsigned int creatorID; + PSITEMSTATS_CREATORSTATUS creatorIDStatus; }; *************** *** 491,494 **** --- 501,505 ---- const csString GetDownCaseName(); void SetName(const char *v); + void SaveName(void); /** Get the Mesh Name for the item. *************** *** 588,591 **** --- 599,606 ---- void SetLiteratureText (const csString&); + /// creator (i.e. author, artist, etc) of creative things + void SetCreator (unsigned int, PSITEMSTATS_CREATORSTATUS); + bool IsThisTheCreator(unsigned int); + public: Index: psitemstats.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/psitemstats.cpp,v retrieving revision 1.115 retrieving revision 1.116 diff -C2 -d -r1.115 -r1.116 *** psitemstats.cpp 4 Sep 2007 16:17:21 -0000 1.115 --- psitemstats.cpp 5 Sep 2007 21:27:59 -0000 1.116 *************** *** 192,195 **** --- 192,198 ---- creativeType = PSITEMSTATS_CREATIVETYPE_NONE; + creatorIDStatus = PSITEMSTATS_CREATOR_UNASSIGNED; // creator not yet been assigned + creatorID = 0; + content.Empty(); } *************** *** 203,207 **** psXMLString contentXML; psXMLTag creativeTag; ! csString creativeTypeStr; // find type of creative thing from <creative type="..."> --- 206,210 ---- psXMLString contentXML; psXMLTag creativeTag; ! csString creativeTypeStr, creatorStr; // find type of creative thing from <creative type="..."> *************** *** 218,221 **** --- 221,240 ---- creativeType = PSITEMSTATS_CREATIVETYPE_SKETCH; + // get the creator (author, artist, etc) + creativeTag.GetTagParm("creator", creatorStr); + if (creatorStr.Length() == 0) + { + creatorIDStatus = PSITEMSTATS_CREATOR_UNASSIGNED; // creator not yet been assigned + creatorID = 0; + } + else + { + creatorID = atoi(creatorStr.GetData()); + if (creatorID == 0) + creatorIDStatus = PSITEMSTATS_CREATOR_UNKNOWN; // creator no longer around + else + creatorIDStatus = PSITEMSTATS_CREATOR_VALID; // valid + } + if (creativeType != PSITEMSTATS_CREATIVETYPE_NONE) { *************** *** 255,264 **** creativeDefinitionXML = "<creative type=\""; if (creativeType == PSITEMSTATS_CREATIVETYPE_LITERATURE) creativeDefinitionXML.Append("literature"); else if (creativeType == PSITEMSTATS_CREATIVETYPE_SKETCH) creativeDefinitionXML.Append("sketch"); ! creativeDefinitionXML.AppendFmt("\"><content>%s</content></creative>", content.GetDataSafe()); } --- 274,291 ---- creativeDefinitionXML = "<creative type=\""; + // start of creative data xml if (creativeType == PSITEMSTATS_CREATIVETYPE_LITERATURE) creativeDefinitionXML.Append("literature"); else if (creativeType == PSITEMSTATS_CREATIVETYPE_SKETCH) creativeDefinitionXML.Append("sketch"); + creativeDefinitionXML.AppendFmt("\""); ! // add author, artist... if necessary ! if (creatorIDStatus != PSITEMSTATS_CREATOR_UNASSIGNED) ! { ! creativeDefinitionXML.AppendFmt(" creator=\"%d\"", creatorID); ! } ! ! creativeDefinitionXML.AppendFmt("><content>%s</content></creative>", content.GetDataSafe()); } *************** *** 271,275 **** litID.Format("%u", uid); ! values.Push(creativeDefinitionXML); if ( !db->GenericUpdateWithID("item_stats", "id", litID, fieldnames, values) ) --- 298,302 ---- litID.Format("%u", uid); ! values.Push(this->creativeDefinitionXML); if ( !db->GenericUpdateWithID("item_stats", "id", litID, fieldnames, values) ) *************** *** 850,853 **** --- 877,897 ---- } + void psItemStats::SaveName(void) + { + // save to database + psStringArray values; + const char *fieldnames[] = {"name"}; + csString itemStatsID; + + itemStatsID.Format("%u", uid); + values.Push(this->name); + + if ( !db->GenericUpdateWithID("item_stats", "id", itemStatsID, fieldnames, values) ) + { + Error2("Failed to save name for item %u!", uid ); + } + + } + const char *psItemStats::GetDescription() { *************** *** 1190,1191 **** --- 1234,1256 ---- } + void psItemStats::SetCreator (unsigned int characterID, PSITEMSTATS_CREATORSTATUS creatorStatus) + { + creativeStats.creatorIDStatus = creatorStatus; + if (creatorStatus == PSITEMSTATS_CREATOR_VALID) + creativeStats.creatorID = characterID; + else if (creatorStatus == PSITEMSTATS_CREATOR_UNKNOWN) + creativeStats.creatorID = 0; + creativeStats.FormatCreativeContent(); + } + + bool psItemStats::IsThisTheCreator(unsigned int characterID) + { + // if characterID is creator of this item, or no creator assigned (then anyone can edit) + if ((creativeStats.creatorIDStatus == PSITEMSTATS_CREATOR_VALID && + creativeStats.creatorID == characterID) || + creativeStats.creatorIDStatus == PSITEMSTATS_CREATOR_UNASSIGNED) + return true; + + return false; + } + |