void dump_npc(npc* n) { printf("NPC<%p> {\n", n); dump_container(&(n->inventory)); printf("\tHP: %d\n", n->hp); dump_item(n->weapon); dump_item(n->armor); }
// Dump an item, its tags, children, and siblings, to stdout. void dump_item(golem_item *item, int indent) { if (item) { for (int i = 0; i < indent; ++i) { putchar(' '); putchar(' '); } printf("%c %s", item_tagged(item, "PC") ? '@' : '*', item->name); for (golem_tag *tag = item->tags; tag; tag = tag->next) { printf("%c%s", tag->sign ? '+' : '-', tag->name); } putchar('\n'); dump_item(item->first_child, indent + 1); if (indent > 0) { dump_item(item->next_sibling, indent); } } }
void scw_dump_out2(scw_out_t* pout,int flag,int wdtype) { scw_item_t item; memset(&item,0,sizeof(item)); // view basic word sep result if(scw_get_item(&item, pout, SCW_OUT_BASIC | SCW_OUT_PROP)>=0){ printf("=================== Basic Word Sep Result =====================\n"); if(flag == 0) dump_item(item); else if(flag == 1) dump_item1(item,wdtype); printf("\n\n"); } if(scw_get_item(&item, pout, SCW_OUT_WPCOMP | SCW_OUT_PROP)>=0){ printf("=================== Word Phrase Result =====================\n"); if(flag == 0) dump_item(item); else if(flag == 1) dump_item1(item,wdtype); printf("\n\n"); } if(scw_get_item(&item, pout, SCW_OUT_SUBPH | SCW_OUT_PROP)>=0){ printf("=================== Sub Phrase Result =====================\n"); if(flag == 0) dump_item(item); else if(flag == 1) dump_item1(item,wdtype); printf("\n\n"); } if(scw_get_item(&item, pout, SCW_OUT_NEWWORD | SCW_OUT_PROP)>=0){ printf("=================== NEW Word Result =====================\n"); if(flag == 0) dump_item(item); else if(flag == 1) dump_item1(item,wdtype); printf("\n\n"); } if(scw_get_item(&item, pout, SCW_OUT_HUMANNAME | SCW_OUT_PROP)>=0){ printf("=================== Humanname Result =====================\n"); if(flag == 0) dump_item(item); else if(flag == 1) dump_item1(item,wdtype); printf("\n\n"); } if(scw_get_item(&item, pout, SCW_OUT_BOOKNAME | SCW_OUT_PROP)>=0){ printf("================== Bookname Result =====================\n"); if(flag == 0) dump_item(item); else if(flag == 1) dump_item1(item,wdtype); printf("\n\n"); } }
void dump_container(container* c) { int x; printf("Container<%p> {\n\tItems: (\n", c); for(x=0; x<c->num_items; ++x) { dump_item(c->items[x]); } printf( "\t)\n" "\tNUM_ITEMS: %d\n" "\tSIZE: %d\n" "}\n", c->num_items, c->size ); }
void dump_item( const Outlook::_AppointmentItemPtr &item, QXmlStreamWriter &stream, bool dump_exception ) { TRACE(OutlookSyncPlugin) << "OutlookDatebookSync::dump_item"; Outlook::OlRecurrenceState recstate = item->GetRecurrenceState(); if ( recstate == Outlook::olApptOccurrence ) { WARNING() << "Cannot sync occurrences!"; return; } if ( (dump_exception && recstate != Outlook::olApptException) || (!dump_exception && recstate == Outlook::olApptException) ) { WARNING() << "Found" << (recstate == Outlook::olApptException?"Exception":"non-Exception") << "when syncing" << (dump_exception?"Exceptions":"non-Exceptions"); return; } Outlook::UserPropertiesPtr props = item->GetUserProperties(); Q_ASSERT(props); PREPARE_MAPI_DATEBOOK(Appointment, dump_exception); stream.writeStartElement("Appointment"); DUMP_STRING(Identifier,EntryID); DUMP_STRING(Description,Subject); DUMP_STRING(Location,Location); QString timezone; { Outlook::UserPropertyPtr up = props->Find("Qtopia Timezone"); if ( up ) { timezone = variant_to_qstring(up->GetValue()); } } DUMP_EXPR(TimeZone,timezone); stream.writeStartElement("When"); if ( item->GetAllDayEvent() ) { DUMP_DATE(StartDate,Start); // We can't just dump the end date because Outlook does it differently to Qtopia. // Qtopia expects something like "starts 7/10/08, ends 7/10/08" but Outlook // has given us "starts 7/10/08 00:00:00, ends 8/10/08 00:00:00". // Simply remove one day from the end date to get something Qtopia won't barf over. QDate dt = date_to_qdatetime(item->GetEnd()).date(); dt = dt.addDays(-1); DUMP_EXPR(EndDate,escape(dateToString(dt))); } else { QDateTime dt = date_to_qdatetime(item->GetStart()); bool utc = !timezone.isEmpty(); if ( utc ) dt = dt.toUTC(); DUMP_EXPR(Start,escape(dateTimeToString(dt, utc))); dt = date_to_qdatetime(item->GetEnd()); if ( utc ) dt = dt.toUTC(); DUMP_EXPR(End,escape(dateTimeToString(dt, utc))); } stream.writeEndElement(); stream.writeStartElement("Alarm"); if ( item->GetReminderSet() ) { DUMP_EXPR(Type,item->GetReminderPlaySound()?"Audible":"Visible"); DUMP_INT(Delay,ReminderMinutesBeforeStart); } stream.writeEndElement(); if ( !dump_exception ) { stream.writeStartElement("Repeat"); if ( recstate != Outlook::olApptNotRecurring && item->GetIsRecurring() ) { Q_ASSERT(recstate == Outlook::olApptMaster); Outlook::RecurrencePatternPtr recpat = item->GetRecurrencePattern(); Q_ASSERT(recpat); Outlook::OlRecurrenceType rectype = recpat->GetRecurrenceType(); LOG() << "recpat->RecurrenceType" << rectype; QString type; if ( rectype == Outlook::olRecursDaily && !recpat->GetDayOfWeekMask() ) type = "Daily"; else if ( ( rectype == Outlook::olRecursDaily && recpat->GetDayOfWeekMask() ) || rectype == Outlook::olRecursWeekly ) type = "Weekly"; else if ( rectype == Outlook::olRecursMonthly ) type = "MonthlyDate"; else if ( ( rectype == Outlook::olRecursMonthNth || rectype == Outlook::olRecursYearNth ) && recpat->GetInstance() != 5 ) type = "MonthlyDay"; else if ( ( rectype == Outlook::olRecursMonthNth || rectype == Outlook::olRecursYearNth ) && recpat->GetInstance() == 5 ) type = "MonthlyEndDay"; else if ( rectype == Outlook::olRecursYearly ) type = "Yearly"; Q_ASSERT(!type.isEmpty()); LOG() << "Type" << type << "Instance" << recpat->GetInstance(); stream.writeStartElement("Type"); stream.writeCharacters(type); stream.writeEndElement(); int frequency = recpat->GetInterval(); LOG() << "recpat->GetInterval" << frequency; if ( rectype == Outlook::olRecursDaily && recpat->GetDayOfWeekMask() ) frequency = 1; stream.writeStartElement("Frequency"); stream.writeCharacters(QString::number(frequency)); stream.writeEndElement(); stream.writeStartElement("Until"); if ( !recpat->GetNoEndDate() ) { LOG() << "recpat->GetPatternEndDate" << date_to_qdatetime(recpat->GetPatternEndDate()).date(); stream.writeCharacters(dateToString(date_to_qdatetime(recpat->GetPatternEndDate()).date())); } stream.writeEndElement(); if ( type == "Weekly" || type == "MonthlyDay" || type == "MonthlyEndDay" ) { stream.writeStartElement("WeekMask"); if ( recpat->GetDayOfWeekMask() ) { int mask = recpat->GetDayOfWeekMask(); LOG() << "recpat->GetDayOfWeekMask" << mask; QStringList list; if ( mask & Outlook::olMonday ) list << "Monday"; if ( mask & Outlook::olTuesday ) list << "Tuesday"; if ( mask & Outlook::olWednesday ) list << "Wednesday"; if ( mask & Outlook::olThursday ) list << "Thursday"; if ( mask & Outlook::olFriday ) list << "Friday"; if ( mask & Outlook::olSaturday ) list << "Saturday"; if ( mask & Outlook::olSunday ) list << "Sunday"; stream.writeCharacters(list.join(" ")); } else { LOG() << "recpat->GetDayOfWeekMask" << 0; } stream.writeEndElement(); } Outlook::ExceptionsPtr exceptions = recpat->GetExceptions(); if ( exceptions ) { int expcount = exceptions->GetCount(); for ( int i = 0; i < expcount; i++ ) { stream.writeStartElement("Exception"); long item_to_get = i+1; Outlook::ExceptionPtr exception = exceptions->Item(item_to_get); Q_ASSERT(exception); DUMP_DATE_ITEM(OriginalDate,OriginalDate,exception); if ( !exception->GetDeleted() ) { Outlook::_AppointmentItemPtr exceptionItem = exception->GetAppointmentItem(); dump_item( exceptionItem, stream, true ); } stream.writeEndElement(); } } } stream.writeEndElement(); } DUMP_MAPI(Notes,Body); stream.writeStartElement("Categories"); foreach ( const QString &category, bstr_to_qstring(item->GetCategories()).split(", ", QString::SkipEmptyParts) ) DUMP_EXPR(Category,category); stream.writeEndElement(); stream.writeEndElement(); }
void dump_item( IDispatchPtr dispatch, QXmlStreamWriter &stream ) { Q_ASSERT( dispatch ); Outlook::_AppointmentItemPtr item( dispatch ); dump_item( item, stream, false ); }
void cDragdrop::drop_item(P_CLIENT ps) // Item is dropped { UOXSOCKET s=ps->GetSocket(); // CHARACTER cc=ps->GetCurrChar(); PKGx08 pkgbuf, *pp=&pkgbuf; pp->Iserial=LongFromCharPtr(buffer[s]+1); pp->TxLoc=ShortFromCharPtr(buffer[s]+5); pp->TyLoc=ShortFromCharPtr(buffer[s]+7); pp->TzLoc=buffer[s][9]; pp->Tserial=LongFromCharPtr(buffer[s]+10); //#define debug_dragg if (clientDimension[s]==3) { // UO:3D clients send SOMETIMES two dragg packets for a single dragg action. // sometimes we HAVE to swallow it, sometimes it has to be interpreted // if UO:3D specific item loss problems are reported, this is probably the code to blame :) // LB P_ITEM pi = FindItemBySerial(pp->Iserial); #ifdef debug_dragg if (i!=-1) { sprintf(temp, "%04x %02x %02x %01x %04x i-name: %s EVILDRAG-old: %i\n",pp->Iserial, pp->TxLoc, pp->TyLoc, pp->TzLoc, pp->Tserial, items[i].name, EVILDRAGG[s]); clConsole.send(temp); } else { sprintf(temp, "blocked: %04x %02x %02x %01x %04x i-name: invalid item EVILDRAG-old: %i\n",pp->Iserial, pp->TxLoc, pp->TyLoc, pp->TzLoc, pp->Tserial, EVILDRAGG[s]); clConsole.send(temp); } #endif if ( (pp->TxLoc==-1) && (pp->TyLoc==-1) && (pp->Tserial==0) && (EVILDRAGG[s]==1) ) { EVILDRAGG[s]=0; #ifdef debug_dragg clConsole.send("Swallow only\n"); #endif return; } // swallow! note: previous evildrag ! else if ( (pp->TxLoc==-1) && (pp->TyLoc==-1) && (pp->Tserial==0) && (EVILDRAGG[s]==0) ) { #ifdef debug_dragg clConsole.send("Bounce & Swallow\n"); #endif item_bounce6(ps, pi); return; } else if ( ( (pp->TxLoc!=-1) && (pp->TyLoc!=-1) && ( pp->Tserial!=-1)) || ( (isItemSerial(pp->Iserial)) && (isItemSerial(pp->Tserial)) ) ) EVILDRAGG[s]=1; // calc new evildrag value else EVILDRAGG[s]=0; } #ifdef debug_dragg else { ITEM i = calcItemFromSer( pp->Iserial ); if (i!=-1) { sprintf(temp, "blocked: %04x %02x %02x %01x %04x i-name: %s EVILDRAG-old: %i\n",pp->Iserial, pp->TxLoc, pp->TyLoc, pp->TzLoc, pp->Tserial, items[i].name, EVILDRAGG[s]); clConsole.send(temp); } } #endif if ( (buffer[s][10]>=0x40) && (buffer[s][10]!=0xff) ) pack_item(ps,pp); else dump_item(ps,pp); }
int main(int argc,char** argv) { scw_worddict_t * pwdict; scw_inner_t *pir; scw_item_t *pitem; char line[1024000]; int flag = 0; int tsize = 0; if(argc!=4){ fprintf(stderr, "usage: %s dictfilename pos outlevel\n", argv[0]); exit(-1); } if((pwdict=scw_load_worddict(argv[1]))==NULL){ fprintf(stderr,"Load worddict failed.Filename=%s\n",argv[1]); return 1; } flag = atoi(argv[2]); tsize = 10000; //tsize = atoi(argv[3]); if(tsize < 1) { fprintf(stderr,"tsize [%s] should > 1\n",argv[3]); return 1; } if((pir=scw_create_inner(tsize, SCW_OUT_ALL | SCW_OUT_PROP))==NULL){ fprintf(stderr,"Init the output buffer error.\n"); return -1; } if((pitem=scw_create_item(tsize))==NULL){ fprintf(stderr, "Init pitem failed\n"); return -1; } set_scw_tn(); while(fgets(line,sizeof(line),stdin)){ //if(++linenum%1000==0) //fprintf(stderr, "%d\n", linenum); int len=strlen(line); while((line[len-1]=='\r') ||(line[len-1]=='\n')) line[--len]=0; if(scw_seg(pwdict,pir,line,len,false) < 0) { fprintf(stderr, "scw_seg return -1!\n"); } /*ret = get_lgt_scw_seg(pwdict, pir); if(ret < 0) { fprintf(stderr, "get_lgt_scw_seg return -1\n"); continue; }*/ switch(atoi(argv[3])) { case 0: printf("============== Basic Word Result =============\n"); if(scw_get_result(pitem, pwdict, pir, SCW_OUT_BASIC | SCW_OUT_PROP)<0){ fprintf(stderr, "get basic seg result error!\n"); continue; } if(flag == 0) dump_item(pitem); else if(flag == 1) dump_item1(pitem,pwdict->m_wdtype); break; case 1: printf("============== Word Phrase Result =============\n"); if(scw_get_result(pitem, pwdict,pir, SCW_OUT_WPCOMP | SCW_OUT_PROP)<0){ fprintf(stderr, "get word/phrase result error!\n"); continue; } if(flag == 0) dump_item(pitem); else if(flag == 1) dump_item1(pitem,pwdict->m_wdtype); break; case 2: printf("============== Sub Phrase Result =============\n"); if(scw_get_result(pitem, pwdict, pir, SCW_OUT_SUBPH | SCW_OUT_PROP)<0){ fprintf(stderr,"get sub phrase result error!\n"); continue; } if(flag == 0) dump_item(pitem); else if(flag == 1) dump_item1(pitem,pwdict->m_wdtype); break; case 3: printf("============== Human Name Result =============\n"); if(scw_get_result(pitem, pwdict, pir, SCW_OUT_HUMANNAME | SCW_OUT_PROP)<0){ fprintf(stderr, "get sub phrase result error!\n"); continue; } if(flag == 0) dump_item(pitem); else if(flag == 1) dump_item1(pitem,pwdict->m_wdtype); break; case 4: printf("============== Book Name Result =============\n"); if(scw_get_result(pitem, pwdict, pir, SCW_OUT_BOOKNAME | SCW_OUT_PROP)<0){ fprintf(stderr,"get sub phrase result error!\n"); continue; } if(flag == 0) dump_item(pitem); else if(flag == 1) dump_item1(pitem,pwdict->m_wdtype); break; case 5: printf("============== Newword Result =============\n"); if(scw_get_result(pitem, pwdict, pir, SCW_OUT_NEWWORD | SCW_OUT_PROP)<0){ fprintf(stderr,"get newword result error!\n"); continue; } if(flag == 0) dump_item(pitem); else if(flag == 1) dump_item1(pitem,pwdict->m_wdtype); break; default: break; } } return 0; }
// Parse all rules from STDIN. int main(int argc, char *argv[]) { golem_world *world = new_world(rules_from_string(slurp_file(stdin))); dump_item(world->current, 0); return 0; }
void drop_item(NXWCLIENT ps) // Item is dropped { if (ps == NULL) return; NXWSOCKET s=ps->toInt(); // CHARACTER cc=ps->currCharIdx(); PKGx08 pkgbuf, *pp=&pkgbuf; pp->Iserial=LongFromCharPtr(buffer[s]+1); pp->TxLoc=ShortFromCharPtr(buffer[s]+5); pp->TyLoc=ShortFromCharPtr(buffer[s]+7); pp->TzLoc=buffer[s][9]; pp->Tserial=LongFromCharPtr(buffer[s]+10); //#define debug_dragg if (clientDimension[s]==3) { // UO:3D clients send SOMETIMES two dragg packets for a single dragg action. // sometimes we HAVE to swallow it, sometimes it has to be interpreted // if UO:3D specific item loss problems are reported, this is probably the code to blame :) // LB P_ITEM pi = pointers::findItemBySerial(pp->Iserial); #ifdef debug_dragg if (ISVALIDPI(pi)) { sprintf(temp, "%04x %02x %02x %01x %04x i-name: %s EVILDRAG-old: %i\n",pp->Iserial, pp->TxLoc, pp->TyLoc, pp->TzLoc, pp->Tserial, pi->name, clientInfo[s]->evilDrag); ConOut(temp); } else { sprintf(temp, "blocked: %04x %02x %02x %01x %04x i-name: invalid item EVILDRAG-old: %i\n",pp->Iserial, pp->TxLoc, pp->TyLoc, pp->TzLoc, pp->Tserial, clientInfo[s]->evilDrag); ConOut(temp); } #endif if ( (pp->TxLoc==-1) && (pp->TyLoc==-1) && (pp->Tserial==0) && (clientInfo[s]->evilDrag) ) { clientInfo[s]->evilDrag=false; #ifdef debug_dragg ConOut("Swallow only\n"); #endif return; } // swallow! note: previous evildrag ! else if ( (pp->TxLoc==-1) && (pp->TyLoc==-1) && (pp->Tserial==0) && (!clientInfo[s]->evilDrag) ) { #ifdef debug_dragg ConOut("Bounce & Swallow\n"); #endif item_bounce6(ps, pi); return; } else if ( ( (pp->TxLoc!=-1) && (pp->TyLoc!=-1) && ( pp->Tserial!=-1)) || ( (pp->Iserial>=0x40000000) && (pp->Tserial>=0x40000000) ) ) clientInfo[s]->evilDrag=true; // calc new evildrag value else clientInfo[s]->evilDrag=false; } #ifdef debug_dragg else { P_ITEM pi = pointers::findItemBySerial(pp->Iserial); if (ISVALIDPI(pi)) { sprintf(temp, "blocked: %04x %02x %02x %01x %04x i-name: %s EVILDRAG-old: %i\n",pp->Iserial, pp->TxLoc, pp->TyLoc, pp->TzLoc, pp->Tserial, pi->name, clientInfo[s]->evilDrag); ConOut(temp); } } #endif // if ( (buffer[s][10]>=0x40) && (buffer[s][10]!=0xff) ) if ( isItemSerial(pp->Tserial) && (pp->Tserial != INVALID) ) // Invalid target => invalid container => put inWorld !!! pack_item(ps,pp); else dump_item(ps,pp); }