int findlandtileflags( int argc, char **argv ) { unsigned long flags = strtoul( argv[1], NULL, 0 ); open_uo_data_files(); read_uo_data(); for( u16 y = 0; y < 4095; ++y ) { for( u16 x = 0; x < 6143; ++x ) { short z; USTRUCT_MAPINFO mi; safe_getmapinfo( x, y, &z, &mi ); if (landtile_uoflags( mi.landtile ) & flags) { cout << x << "," << y << "," << (int) mi.z; cout << ": landtile " << hexint(mi.landtile) << ", flags " << hexint( landtile_uoflags( mi.landtile ) ); cout << endl; } } } clear_tiledata(); return 0; }
int findgraphic( int argc, char **argv ) { int graphic = strtoul( argv[1], NULL, 0 ); cout << "Searching map for statics with graphic=" << hexint(graphic) << endl; open_uo_data_files(); read_uo_data(); for( u16 y = 0; y < 4095; ++y ) { for( u16 x = 0; x < 6143; ++x ) { StaticList statics; readallstatics( statics, x, y ); for( unsigned i = 0; i < statics.size(); ++i ) { StaticRec& rec = statics[i]; if (rec.graphic == graphic) { cout << x << "," << y << "," << rec.z << endl; } } } } clear_tiledata(); return 0; }
// scripted_create duplicates some of this work //Dave changed 3/8/3 to use objecthash UMulti* UMulti::create( const ItemDesc& descriptor, u32 serial ) { UMulti* multi = NULL; if ( descriptor.type == ItemDesc::BOATDESC ) { multi = new UBoat( descriptor ); } else if ( descriptor.type == ItemDesc::HOUSEDESC ) { multi = new UHouse( descriptor ); } else { cerr << "Tried to create multi " << hexint(descriptor.objtype) << " but no definition exists in itemdesc.cfg" << endl; return NULL; } if (serial) multi->serial = UseItemSerialNumber( serial ); else multi->serial = GetNewItemSerialNumber(); multi->serial_ext = ctBEu32( multi->serial ); ////HASH objecthash.Insert(multi); //// return multi; }
Item* Item::create( u16 objtype, u32 serial ) { const ItemDesc& id = find_itemdesc( objtype ); if (&id != &empty_itemdesc) { return create( id, serial ); } else if (objtype <= config.max_tile_id) { temp_itemdesc.objtype = objtype; temp_itemdesc.graphic = objtype; return create( temp_itemdesc, serial ); } else { string message = "Objtype not defined: " + hexint( objtype ); if ( !config.ignore_load_errors ) throw runtime_error( message ); else { cerr << message << endl; return NULL; } } }
bool OSExecutorModule::signal_event( BObjectImp* imp ) { INC_PROFILEVAR(events); if (blocked_ && (wait_type == WAIT_EVENT)) // already being waited for { /* Now, the tricky part. The value to return on an error or completion condition has already been pushed onto the value stack - so, we need to replace it with the real result. */ exec.ValueStack.top().set( new BObject( imp ) ); /* This executor will get moved to the run queue at the next step_scripts(), where blocked is checked looking for timed out or completed operations. */ revive(); } else // not being waited for, so queue for later. { if (events_.size() < max_eventqueue_size) { events_.push( imp ); } else { if (config.discard_old_events) { BObject ob( events_.front() ); events_.pop(); events_.push( imp ); } else { if (config.loglevel >= 11) { cout << "Event queue for " << exec.scriptname() << " is full, discarding event." << endl; ExecutorModule* em = exec.findModule( "npc" ); if (em) { NPCExecutorModule* npcemod = static_cast<NPCExecutorModule*>(em); cout << "NPC Serial: " << hexint( npcemod->npc.serial ) << " (" << npcemod->npc.x << " " << npcemod->npc.y << " " << (int) npcemod->npc.z << ")" << endl; } BObject ob( imp ); cout << "Event: " << ob->getStringRep() << endl; } return false; } } } return true; }
char *amqp_util_encode(char *key, char *dest) { char *p, *end; if ((strlen(key) == 1) && (key[0] == '#' || key[0] == '*')) { *dest++ = key[0]; *dest = '\0'; return dest; } for (p = key, end = key + strlen(key); p < end; p++) { if (KEY_SAFE(*p)) { *dest++ = *p; } else if (*p == '.') { memcpy(dest, "%2E", 3); dest += 3; } else if (*p == ' ') { *dest++ = '+'; } else { *dest++ = '%'; sprintf(dest, "%c%c", hexint(HI4(*p)), hexint(LO4(*p))); dest += 2; } } *dest = '\0'; return dest; }
void uo_client_listener_thread( void* arg ) { UoClientListener* ls = reinterpret_cast<UoClientListener*>(arg); atomic_cout( "Listening for UO clients on port " + decint(ls->port) + " (encryption: " + decint(ls->encryption.eType) + "," + hexint(ls->encryption.uiKey1) + "," + hexint(ls->encryption.uiKey2) + ")"); SocketListener SL( ls->port, Socket::option(Socket::nonblocking|Socket::reuseaddr) ); while (!exit_signalled) { if (SL.GetConnection( 5 )) { // create an appropriate Client object SocketClientThread* thread = new UoClientThread( ls, SL ); thread->start(); } } }
BObjectImp* PolSystemExecutorModule::mf_GetItemDescriptor() { unsigned short objtype; if (getObjtypeParam( exec, 0, objtype )) { const ItemDesc& id = find_itemdesc( objtype ); if(id.objtype == 0 && id.graphic == 0) return new BError( "Itemdesc.cfg entry for objtype " + hexint(objtype) + " not found." ); auto_ptr<BStruct> descriptor(new BStruct()); id.PopulateStruct( descriptor.get() ); return descriptor.release(); } else { return new BError( "Invalid parameter type" ); } }
int mapdump( int argc, char* argv[] ) { u16 wxl = 5485, wxh = 5500, wyl=0, wyh=30; if (argc >= 4) { wxl = wxh = static_cast<u16>(atoi( argv[2] )); wyl = wyh = static_cast<u16>(atoi( argv[3] )); } if (argc >= 6) { wxh = static_cast<u16>(atoi( argv[4] )); wyh = static_cast<u16>(atoi( argv[5] )); } open_uo_data_files(); read_uo_data(); ofstream ofs( "mapdump.html" ); ofs << "<table border=1 cellpadding=5 cellspacing=0>" << endl; ofs << "<tr><td> </td>"; for( u16 x = wxl; x <= wxh; ++x ) { ofs << "<td align=center>" << x << "</td>"; } ofs << "</tr>" << endl; for( u16 y = wyl; y <= wyh; ++y ) { ofs << "<tr><td valign=center>" << y << "</td>" << endl; for( u16 x = wxl; x <= wxh; ++x ) { ofs << "<td align=left valign=top>"; short z; USTRUCT_MAPINFO mi; safe_getmapinfo( x, y, &z, &mi ); USTRUCT_LAND_TILE landtile; readlandtile( mi.landtile, &landtile ); ofs << "z=" << z << "<br>"; ofs << "landtile=" << hexint(mi.landtile) << " " << landtile.name << "<br>"; ofs << " flags=" << hexint( landtile.flags ) << "<br>"; ofs << "mapz=" << (int)mi.z << "<br>"; StaticList statics; readallstatics( statics, x, y ); if (!statics.empty()) { ofs << "<table border=1 cellpadding=5 cellspacing=0>" << endl; ofs << "<tr><td>graphic</td><td>z</td><td>flags</td><td>ht</td>" << endl; for( unsigned i = 0; i < statics.size(); ++i ) { ofs << "<tr>"; StaticRec& rec = statics[i]; ofs << "<td>" << hexint( rec.graphic ) << "</td>"; ofs << "<td>" << int(rec.z) << "</td>"; ofs << "<td>" << hexint( rec.flags ) << "</td>"; ofs << "<td>" << int(rec.height) << "</td>"; ofs << "</tr>" << endl; } ofs << "</table>" << endl; } ofs << "</td>" << endl; } ofs << "</tr>" << endl; } ofs << "</table>" << endl; clear_tiledata(); return 0; }