void debug_int_space(int n,int fieldsz) { char str[256]; sprintf(str,"%d",n); debug_space(str,fieldsz); }
void debug_space_tag(unsigned long tag,int fieldsz) { char str[256]; memmove(str,&tag,4); str[4]=0x0; debug_space(str,fieldsz); }
int repair_everything (void) { register int i; if (sdb[n].aux.exist) sdb[n].aux.damage = 1.0; if (sdb[n].batt.exist) sdb[n].batt.damage = 1.0; if (sdb[n].beam.exist) for (i = 0; i < sdb[n].beam.banks; ++i) sdb[n].blist.damage[i] = 1.0; if (sdb[n].missile.exist) for (i = 0; i < sdb[n].missile.tubes; ++i) sdb[n].mlist.damage[i] = 1.0; if (sdb[n].cloak.exist) sdb[n].cloak.damage = 1.0; if (sdb[n].engine.warp_exist) sdb[n].engine.warp_damage = 1.0; if (sdb[n].engine.impulse_exist) sdb[n].engine.impulse_damage = 1.0; if (sdb[n].main.exist) sdb[n].main.damage = 1.0; if (sdb[n].sensor.ew_exist) sdb[n].sensor.ew_damage = 1.0; if (sdb[n].sensor.lrs_exist) sdb[n].sensor.lrs_damage = 1.0; if (sdb[n].sensor.srs_exist) sdb[n].sensor.srs_damage = 1.0; if (sdb[n].shield.exist) for (i = 0; i < MAX_SHIELD_NAME; ++i) sdb[n].shield.damage[i] = 1.0; sdb[n].status.crippled = 0; sdb[n].structure.superstructure = sdb[n].structure.max_structure; sdb[n].structure.repair = sdb[n].structure.max_repair; if (sdb[n].trans.exist) sdb[n].trans.damage = 1.0; if (sdb[n].tract.exist) sdb[n].tract.damage = 1.0; sdb[n].sensor.version = 1; sdb[n].engine.version = 1; sdb[n].power.version = 1; sdb[n].cloak.version = 1; up_cochranes(); up_empire(); up_quadrant(); up_vectors(); up_resolution(); up_signature(n); up_visibility(); debug_space(n); return 1; }
void damage_structure (int x, double damage) { register int i; double s = sdb[x].structure.superstructure; if (sdb[x].structure.superstructure == -sdb[x].structure.max_structure) return; sdb[x].structure.superstructure -= damage; if (sdb[x].structure.superstructure < -sdb[x].structure.max_structure) sdb[x].structure.superstructure = -sdb[x].structure.max_structure; do_console_notify(x, console_engineering, console_damage, 0, ansi_alert(tprintf("%s%s%s: %s %s", ANSI_CYAN, system_name[0], ANSI_WHITE, unparse_percent(sdb[x].structure.superstructure / sdb[x].structure.max_structure), unparse_damage(sdb[x].structure.superstructure / sdb[x].structure.max_structure)))); if ((sdb[x].structure.superstructure <= -sdb[x].structure.max_structure) && (s > -sdb[x].structure.max_structure)) { /* Mordak Aspace v1.0.0p1 - Removed Silly KayBye! */ do_ship_notify(x, tprintf("%s%s%s%s explodes into white hot vapor.%s%s", ANSI_HILITE, ANSI_INVERSE, ANSI_RED, Name(sdb[x].object), ANSI_WHITE, ANSI_NORMAL)); /* End Aspace v1.0.0p1*/ do_space_notify_one(x, console_helm, console_tactical, console_science, "has been destroyed"); write_spacelog(sdb[x].object, sdb[x].object, tprintf("LOG: Destroyed, Shields %.6f GHz", sdb[x].shield.freq)); sdb[x].space = -1; sdb[x].status.active = 0; sdb[x].status.crippled = 2; for (i = MIN_SPACE_OBJECTS ; i <= max_space_objects ; ++i) if (sdb[i].location == x) if (sdb[i].structure.type) { do_ship_notify(i, tprintf("%s%s%s%s explodes into white hot vapor. Goodbye!%s%s", ANSI_HILITE, ANSI_INVERSE, ANSI_RED, Name(sdb[i].object), ANSI_WHITE, ANSI_NORMAL)); write_spacelog(sdb[x].object, sdb[x].object, tprintf("LOG: Destroyed, Shields %.6f GHz", sdb[x].shield.freq)); sdb[i].space = -1; sdb[i].status.active = 0; sdb[i].status.crippled = 2; } } else if ((sdb[x].structure.superstructure <= 0.0) && (s > 0.0)) { do_all_console_notify(x, ansi_warn("Excessive damage. All systems shutting down")); do_ship_notify(x, tprintf("%s experiences total systems failure.",Name(sdb[x].object))); sdb[x].status.crippled = 1; do_space_notify_one(x, console_helm, console_tactical, console_science, "has been disabled"); write_spacelog(sdb[x].object, sdb[x].object, tprintf("LOG: Disabled, Shields %.6f GHz", sdb[x].shield.freq)); } if (((sdb[x].structure.superstructure <= 0.0) && (s > 0.0)) || ((sdb[x].structure.superstructure <= -sdb[x].structure.max_structure) && (s > -sdb[x].structure.max_structure))) { if (sdb[x].main.damage > 0.0) sdb[x].main.in = 0.0; if (sdb[x].aux.damage > 0.0) sdb[x].aux.in = 0.0; for (i = 0; i < MAX_SHIELD_NAME; ++i) sdb[x].shield.active[i] = 0; sdb[x].beam.in = 0.0; sdb[x].beam.out = 0.0; for (i = 0; i < sdb[x].beam.banks; ++i) { sdb[x].blist.lock[i] = 0; sdb[x].blist.active[i] = 0; } sdb[x].missile.in = 0.0; sdb[x].missile.out = 0.0; for (i = 0; i < sdb[x].missile.tubes; ++i) { sdb[x].mlist.lock[i] = 0; sdb[x].mlist.active[i] = 0; } sdb[x].batt.in = 0.0; sdb[x].batt.out = 0.0; sdb[x].move.in = 0.0; sdb[x].move.out = 0.0; sdb[x].move.v = 0.0; sdb[x].engine.warp_max = 0.0; sdb[x].engine.impulse_max = 0.0; sdb[x].power.batt = 0.0; sdb[x].sensor.lrs_active = 0; sdb[x].sensor.srs_active = 0; sdb[x].sensor.ew_active = 0; sdb[x].cloak.active = 0; sdb[x].trans.active = 0; sdb[x].trans.d_lock = 0; sdb[x].trans.s_lock = 0; sdb[x].tract.active = 0; sdb[x].tract.lock = 0; if (GoodSDB(sdb[x].status.tractoring)) { sdb[sdb[x].status.tractoring].status.tractored = 0; sdb[x].status.tractoring = 0; } up_cochranes(); up_empire(); up_quadrant(); up_vectors(); up_resolution(); up_signature(x); up_visibility(); debug_space(x); } return; }
void debug_node(union node *node, int depth) { debug_unquoted("type", debug_nodes[node->id], depth); debug_space(depth); switch(node->id) { case N_SIMPLECMD: debug_ulong("bngd", node->ncmd.bgnd, depth); debug_space(depth); debug_sublist("rdir", node->ncmd.rdir, depth); debug_space(depth); debug_sublist("args", node->ncmd.args, depth); debug_space(depth); debug_sublist("vars", node->ncmd.vars, depth); break; case N_PIPELINE: debug_ulong("bgnd", node->npipe.bgnd, depth); debug_space(depth); debug_sublist("cmds", node->npipe.cmds, depth); debug_space(depth); debug_ulong("ncmd", node->npipe.ncmd, depth); break; case N_AND: case N_OR: debug_ulong("bgnd", node->nandor.bgnd, depth); debug_space(depth); debug_subnode("cmd0", node->nandor.cmd0, depth); debug_space(depth); debug_subnode("cmd1", node->nandor.cmd1, depth); break; case N_SUBSHELL: case N_CMDLIST: debug_sublist("rdir", node->ngrp.rdir, depth); debug_space(depth); debug_sublist("cmds", node->ngrp.cmds, depth); break; case N_FOR: debug_str("varn", node->nfor.varn, depth); debug_space(depth); debug_sublist("cmds", node->nfor.cmds, depth); debug_space(depth); debug_sublist("args", node->nfor.args, depth); break; case N_CASE: debug_ulong("bgnd", node->ncase.bgnd, depth); debug_space(depth); debug_sublist("rdir", node->ncase.rdir, depth); debug_space(depth); debug_sublist("list", node->ncase.list, depth); debug_space(depth); debug_sublist("word", node->ncase.word, depth); break; case N_CASENODE: debug_sublist("pats", node->ncasenode.pats, depth); debug_space(depth); debug_sublist("cmds", node->ncasenode.cmds, depth); break; case N_IF: debug_ulong("bgnd", node->nif.bgnd, depth); debug_space(depth); debug_sublist("rdir", node->nif.rdir, depth); debug_space(depth); debug_sublist("cmd0", node->nif.cmd0, depth); debug_space(depth); debug_sublist("cmd1", node->nif.cmd1, depth); debug_space(depth); debug_subnode("test", node->nif.test, depth); break; case N_WHILE: case N_UNTIL: debug_ulong("bgnd", node->nloop.bgnd, depth); debug_space(depth); debug_sublist("rdir", node->nif.rdir, depth); debug_space(depth); debug_sublist("cmds", node->nloop.test, depth); debug_space(depth); debug_subnode("test", node->nloop.test, depth); break; case N_FUNCTION: debug_sublist("cmds", node->nfunc.cmds, depth); debug_space(depth); debug_str("name", node->nfunc.name, depth); break; case N_ASSIGN: case N_ARG: debug_subst("flag", node->narg.flag, depth); debug_space(depth); debug_stralloc("stra", &node->narg.stra, depth); debug_space(depth); debug_sublist("list", node->narg.list, depth); break; case N_REDIR: debug_redir("flag", node->nredir.flag, depth); debug_space(depth); debug_sublist("list", node->nredir.list, depth); debug_space(depth); debug_sublist("data", node->nredir.data, depth); debug_space(depth); debug_ulong("fdes", node->nredir.fdes, depth); break; case N_ARGSTR: debug_subst("flag", node->nargstr.flag, depth); debug_space(depth); debug_stralloc("stra", &node->nargstr.stra, depth); break; case N_ARGPARAM: debug_subst("flag", node->nargparam.flag, depth); debug_space(depth); debug_str("name", node->nargparam.name, depth); debug_space(depth); debug_sublist("word", node->nargparam.word, depth); debug_space(depth); debug_ulong("numb", node->nargparam.numb, depth); break; case N_ARGCMD: case N_ARGARITH: debug_subst("flag", node->nargcmd.flag, depth); debug_space(depth); debug_sublist("list", node->nargcmd.list, depth); break; case N_NOT: debug_sublist("cmds", node->nandor.cmd0, depth); break; } }
/* begin a {}-block * ----------------------------------------------------------------------- */ void debug_begin(const char *s, int depth) { debug_space(depth); buffer_putm(fd_err->w, COLOR_YELLOW, s, COLOR_CYAN, DEBUG_EQU, DEBUG_BEGIN, COLOR_NONE, NULL); }
void debug_dump(void) { int i,idx,cnt,mem_sz; obj_type *obj; effect_type *effect; proj_type *proj; weapon_type *weap; proj_setup_type *proj_setup; model_type *mdl; script_type *script; timer_type *timer; SDL_version *sdl_ver; console_add_system("Debugging info dumped to stdout"); fprintf(stdout,"\n\n"); fprintf(stdout,"#########################################################################\n"); fprintf(stdout,"Dump: dim3 Debugging Info\n"); fprintf(stdout,"Engine v%s\n",dim3_version); fprintf(stdout,"(c) 2000-2007 Klink! Software\n"); fprintf(stdout,"#########################################################################\n\n"); // game info fprintf(stdout,"**************************************\n"); fprintf(stdout,"Game\n"); fprintf(stdout,"**************************************\n\n"); fprintf(stdout,"Project: %s\n",net_setup.host.proj_name); fprintf(stdout,"Tick: %d\n",game_time_get()); debug_return(); // system info fprintf(stdout,"**************************************\n"); fprintf(stdout,"System\n"); fprintf(stdout,"**************************************\n\n"); fprintf(stdout,"Arch Type: %s\n",arch_type); #ifdef D3_OS_MAC fprintf(stdout,"OS Version: %d.%d.%d\n",os_vers_major,os_vers_minor_1,os_vers_minor_2); #endif sdl_ver=(SDL_version*)SDL_Linked_Version(); fprintf(stdout,"SDL Version: %d.%d.%d\n",sdl_ver->major,sdl_ver->minor,sdl_ver->patch); fprintf(stdout,"JavaScript Version: %.2f\n",((float)JS_VERSION/100.0f)); fprintf(stdout,"PNG Version: %s\n",PNG_LIBPNG_VER_STRING); debug_return(); // video info fprintf(stdout,"**************************************\n"); fprintf(stdout,"Video\n"); fprintf(stdout,"**************************************\n\n"); fprintf(stdout,"Engine: %s\n",render_info.name); fprintf(stdout,"Screen: %d,%d at %d\n",render_info.monitor_x_sz,render_info.monitor_y_sz,render_info.monitor_refresh_rate); fprintf(stdout,"Max Texture Units: %d\n",render_info.texture_unit_count); fprintf(stdout,"Max Texture Size: %d\n",render_info.texture_max_size); if (!gl_check_frame_buffer_ok()) fprintf(stdout,"Shadow support disabled; Unsupported on this video card.\n"); if (!gl_check_fsaa_ok()) fprintf(stdout,"FSAA support disabled; Unsupported on this video card.\n"); if (!gl_check_texture_compress_ok()) fprintf(stdout,"Compression disabled; Unsupported on this video card.\n"); if (!gl_check_point_sprite_ok()) fprintf(stdout,"Point sprite support disabled; Unsupported on this video card.\n"); if (!gl_check_shader_ok()) fprintf(stdout,"GLSL support disabled; Unsupported on this video card.\n"); fprintf(stdout,"Extensions:\n%s\n",render_info.ext_string); #ifdef D3_OS_WINDOWS fprintf(stdout,"WGL Extensions:\n%s\n",wglGetExtensionsStringARB(wglGetCurrentDC())); #endif debug_return(); // map info fprintf(stdout,"**************************************\n"); fprintf(stdout,"Map\n"); fprintf(stdout,"**************************************\n\n"); fprintf(stdout,"Map: %s\n",map.info.name); fprintf(stdout,"Author: %s\n",map.info.author); fprintf(stdout,"Mesh Count: %d\n",map.mesh.nmesh); fprintf(stdout,"Liquid Count: %d\n",map.liquid.nliquid); fprintf(stdout,"Spot Count: %d\n",map.nspot); fprintf(stdout,"Scenery Count: %d\n",map.nscenery); fprintf(stdout,"Node Count: %d\n",map.nnode); debug_return(); // objects debug_header("Objects",server.count.obj,(sizeof(obj_type)*server.count.obj)); debug_space("Name",25); debug_space("Type",15); debug_space("Script",25); debug_space("Binding",10); debug_return(); debug_space("------------------------",25); debug_space("------------------------",15); debug_space("------------------------",25); debug_space("---------",10); debug_return(); obj=server.objs; for ((i=0);(i!=server.count.obj);i++) { debug_space(obj->name,25); debug_space(obj->type,15); if (!obj->scenery.on) { idx=scripts_find_uid(obj->attach.script_uid); debug_space(js.scripts[idx].name,25); } else { debug_space("*",25); } debug_space(bind_type_str[obj->bind],10); debug_return(); obj++; } debug_return(); // weapons debug_header("Weapons",server.count.weapon,(sizeof(weapon_type)*server.count.weapon)); debug_space("Name",20); debug_space("Object",20); debug_return(); debug_space("-------------------",20); debug_space("-------------------",20); debug_return(); weap=server.weapons; for ((i=0);(i!=server.count.weapon);i++) { obj=object_find_uid(weap->obj_uid); debug_space(weap->name,20); debug_space(obj->name,20); debug_return(); weap++; } debug_return(); // projectile setups debug_header("Projectile Setups",server.count.proj_setup,(sizeof(proj_setup_type)*server.count.proj_setup)); debug_space("Name",20); debug_space("Object",20); debug_space("Weapon",20); debug_return(); debug_space("-------------------",20); debug_space("-------------------",20); debug_space("-------------------",20); debug_return(); proj_setup=server.proj_setups; for ((i=0);(i!=server.count.proj_setup);i++) { obj=object_find_uid(proj_setup->obj_uid); weap=weapon_find_uid(proj_setup->weap_uid); debug_space(proj_setup->name,20); debug_space(obj->name,20); debug_space(weap->name,20); debug_return(); proj_setup++; } debug_return(); // models mem_sz=sizeof(model_type)*server.count.model; mdl=server.models; for (i=0;i!=server.count.model;i++) { mem_sz+=model_memory_size(mdl); mdl++; } debug_header("Models",server.count.model,mem_sz); debug_space("Name",32); debug_space("Vertexes",10); debug_space("Trigs",10); debug_space("Ref Count",10); debug_return(); debug_space("------------------------------",32); debug_space("---------",10); debug_space("---------",10); debug_space("---------",10); debug_return(); mdl=server.models; for (i=0;i!=server.count.model;i++) { debug_space(mdl->name,32); debug_int_space(mdl->meshes[0].nvertex,10); debug_int_space(mdl->meshes[0].ntrig,10); debug_int_space(mdl->reference_count,10); debug_return(); mdl++; } debug_return(); // projectiles debug_header("Projectiles",server.count.proj,(sizeof(proj_type)*max_projectile)); debug_space("Name",20); debug_space("Object",20); debug_space("Weapon",20); debug_return(); debug_space("-------------------",20); debug_space("-------------------",20); debug_space("-------------------",20); debug_return(); proj=server.projs; for ((i=0);(i!=server.count.proj);i++) { obj=object_find_uid(proj->obj_uid); weap=weapon_find_uid(proj->weap_uid); proj_setup=proj_setups_find_uid(proj->proj_setup_uid); debug_space(proj_setup->name,20); debug_space(obj->name,20); debug_space(weap->name,20); debug_return(); proj++; } debug_return(); // effects debug_header("Effects",server.count.effect,(sizeof(effect_type)*max_effect)); debug_space("Type",10); debug_space("Life Tick",10); debug_return(); debug_space("---------",10); debug_space("---------",10); debug_return(); effect=server.effects; for ((i=0);(i!=server.count.effect);i++) { debug_space(effect_type_str[effect->effecttype],10); debug_int_space(effect->life_tick,10); debug_return(); effect++; } debug_return(); // scripts script=js.scripts; cnt=0; for ((i=0);(i!=max_scripts);i++) { if (script->used) cnt++; script++; } debug_header("Scripts",cnt,-1); debug_space("Name",32); debug_return(); debug_space("-------------------------------",32); debug_return(); script=js.scripts; for ((i=0);(i!=max_scripts);i++) { if (script->used) { debug_space(script->name,32); debug_return(); } script++; } debug_return(); // timers debug_header("Timers",js.count.timer,-1); debug_space("Script",32); debug_space("Count",10); debug_space("Type",10); debug_return(); debug_space("-------------------------------",32); debug_space("---------",10); debug_space("---------",10); debug_return(); timer=js.timers; for ((i=0);(i!=js.count.timer);i++) { script=&js.scripts[scripts_find_uid(timer->attach.script_uid)]; debug_space(script->name,32); debug_int_space(timer->count,10); debug_space((timer->mode==timer_mode_repeat)?"Timer":"Wait",10); debug_return(); timer++; } debug_return(); fflush(stdout); }