-+-+-+-+-+-+-+-+ START OF PART 12 -+-+-+-+-+-+-+-+ Xprocedure freename; Xbegin X perf('freename'); X unlock(namefile); Xend; X X`5Basynchronous`5D Xprocedure getroom(n:integer:= 0); Xvar X err: integer; Xbegin X if not valid_index(i_room,n) then n := pl`5Bnow`5D.where.r; X perf('getroom'); X roomfile`5E.valid := 0; X err := 0; X find(roomfile,n,error := continue); X while roomfile`5E.valid <> n do X begin X deadcheck(err,'getroom'); X collision_wait; X find(roomfile,n,error := continue); X end; X here := roomfile`5E; Xend; X X`5Basynchronous`5D `20 Xprocedure putroom; Xbegin X perf('putroom'); X locate(roomfile,here.valid); X roomfile`5E := here; X put(roomfile); Xend; X `20 X`5Basynchronous`5D Xprocedure freeroom; Xbegin`20 X perf('freeroom'); X unlock(roomfile); Xend; X X`5Basynchronous`5D Xprocedure getfg(n:integer:= 0); Xvar X err:integer; Xbegin X if not valid_index(i_room,n) then n := pl`5Bnow`5D.where.r; X fgfile`5E.valid := 0; X err := 0; X find(fgfile,n,error := continue); X while fgfile`5E.valid <> n do X begin X deadcheck(err,'getfg'); X collision_wait; X find(fgfile,n,error := continue); X end; X fg := fgfile`5E; Xend; X X`5Basynchronous`5D `20 Xprocedure putfg; Xbegin X perf('putfg'); X locate(fgfile,here.valid); X fgfile`5E := fg; X put(fgfile); Xend; X `20 X`5Basynchronous`5D Xprocedure freefg; Xbegin X perf('freefg'); X unlock(fgfile); Xend; X X`5Basynchronous`5D Xprocedure getplayer(n:integer); Xvar X err:integer; Xbegin X perf('getplayer'); X if valid_index(i_player,n) then X begin X err := 0; X playerfile`5E.valid := 0; X find(playerfile,n,error := continue); X while playerfile`5E.valid <> n do X begin X deadcheck(err,'getplayer'); X collision_wait; X find(playerfile,n,error := continue); X end; X player := playerfile`5E; X end; Xend; X X`5Basynchronous`5D Xprocedure putplayer; Xbegin X perf('putplayer'); X locate(playerfile,player.valid); X playerfile`5E := player; X put(playerfile); Xend; X X`5Basynchronous`5D Xprocedure freeplayer; Xbegin X perf('freeplayer'); X unlock(playerfile); Xend; X `20 X`5Basynchronous`5D Xprocedure getobj(n:integer); Xvar X err:integer; Xbegin X perf('getobj'); X if valid_index(i_object,n) then X begin X objfile`5E.valid := 0; X err := 0; X find(objfile,n,error := continue); X while objfile`5E.valid <> n do X begin X deadcheck(err,'getobj'); X collision_wait; X find(objfile,n,error := continue); X end; X obj := objfile`5E; X end; Xend; X X`5Basynchronous`5D Xprocedure putobj; Xbegin X perf('putobj '); X locate(objfile,obj.valid); X objfile`5E := obj; X put(objfile); Xend; X X`5Basynchronous`5D Xprocedure freeobj; Xbegin X perf('freeobj'); X unlock(objfile); Xend; X X`5Basynchronous`5D Xprocedure read_object(n:integer); Xbegin X if obj.valid <> n then X begin X getobj(n); X freeobj; X end; Xend; X X`5Basynchronous`5D Xprocedure getspell(n:integer); Xvar X err:integer; Xbegin X perf('getspell'); X if valid_index(i_spell,n) then X begin X spellfile`5E.valid := 0; X err := 0; X find(spellfile,n,error := continue); X while spellfile`5E.valid <> n do X begin X deadcheck(err,'getspell'); X collision_wait; X find(spellfile,n,error := continue); X end; X spell := spellfile`5E; X end; Xend; X X`5Basynchronous`5D Xprocedure putspell; Xbegin X perf('putspell '); X locate(spellfile,spell.valid); X spellfile`5E := spell; X put(spellfile); Xend; X X`5Basynchronous`5D Xprocedure freespell; Xbegin X perf('freespell'); X unlock(spellfile); Xend; X Xprocedure typefile(filename:string); Xvar X textfile:text; X aline:string; X error:boolean; Xbegin X error := false; X open(textfile,filename,history := old,sharing := readonly, X`09error := continue); X reset(textfile); X repeat X if not eof (textfile) then X begin X readln(textfile,aline); X wl(aline); X end X else error := true; X until error; X close(textfile); Xend; X X`5Basynchronous`5D Xprocedure player_stats; Xbegin X if player.valid <> plr`5Bnow`5D.log then X begin X getplayer(plr`5Bnow`5D.log); X freeplayer; X end; X pl`5Bnow`5D := player; X with person`5Bplr`5Bnow`5D.log`5D do X begin X loc.x := pl`5Bnow`5D.where.x; X loc.y := pl`5Bnow`5D.where.y; X end; Xend; X X`5Basynchronous`5D Xprocedure stats; Xvar X i:integer; X X procedure race_stats; X begin X if race.valid <> pl`5Bnow`5D.attrib_ex`5Bst_race`5D then X begin X getrace(pl`5Bnow`5D.attrib_ex`5Bst_race`5D); X freerace; X end; X with race do X begin X for i := 1 to el_max do X begin X pl`5Bnow`5D.proficiency`5Bi`5D := pl`5Bnow`5D.proficiency`5Bi`5D + r Vace.proficiency`5Bi`5D; X plr`5Bnow`5D.armor`5Bi`5D.chance := armor`5Bi`5D.chance; X plr`5Bnow`5D.armor`5Bi`5D.magnitude := armor`5Bi`5D.magnitude; X plr`5Bnow`5D.sound := sound; X plr`5Bnow`5D.hands := hands; X plr`5Bnow`5D.n_weapon := weapon; X end; X for i := 1 to at_max do X if not (human and (i in `5Bat_wealth,at_points`5D)) then X begin X`09pl`5Bnow`5D.attrib_max`5Bi`5D := pl`5Bnow`5D.attrib_max`5Bi`5D + attrib`5 VBi`5D; X`09if i <> at_points then`20 X`09pl`5Bnow`5D.attrib`5Bi`5D := pl`5Bnow`5D.attrib`5Bi`5D + attrib`5Bi`5D; X end; X end; X end; X X procedure class_stats; X begin X with class`5Bpl`5Bnow`5D.attrib_ex`5Bst_class`5D`5D do X begin X for i := 1 to at_max do X if not (human and (i in `5Bat_wealth,at_points`5D)) then X begin X`09pl`5Bnow`5D.attrib_max`5Bi`5D := pl`5Bnow`5D.attrib_max`5Bi`5D + attrib`5 VBi`5D; X`09if i <> at_points then pl`5Bnow`5D.attrib`5Bi`5D := pl`5Bnow`5D.attrib`5B Vi`5D + attrib`5Bi`5D; X end; X for i := 1 to el_max do X pl`5Bnow`5D.proficiency`5Bi`5D := pl`5Bnow`5D.proficiency`5Bi`5D + pro Vficiency`5Bi`5D; X end; X end; X X procedure condition_stats; X begin X for i := 1 to ps_max do X if pl`5Bnow`5D.sts`5Bi`5D.on then X pl`5Bnow`5D.sts`5Bi`5D.time := pl`5Bnow`5D.sts`5Bi`5D.time + getticks; X end; X Xbegin X race_stats; X class_stats; X condition_stats; X equip_stats(false); Xend; X X`5Basynchronous`5D Xprocedure hack_stats; Xvar X i:integer; X X procedure hack_race_stats; X begin X if race.valid <> pl`5Bnow`5D.attrib_ex`5Bst_race`5D then X begin X getrace(pl`5Bnow`5D.attrib_ex`5Bst_race`5D); X freerace; X end; X with race do X begin X for i := 1 to at_max do X if not (human and (i in `5Bat_wealth,at_points`5D)) then X begin X`09pl`5Bnow`5D.attrib`5Bi`5D := pl`5Bnow`5D.attrib`5Bi`5D - attrib`5Bi`5D; X`09pl`5Bnow`5D.attrib_max`5Bi`5D := pl`5Bnow`5D.attrib_max`5Bi`5D - attrib`5 VBi`5D; X end; X for i := 1 to el_max do X`09pl`5Bnow`5D.proficiency`5Bi`5D := pl`5Bnow`5D.proficiency`5Bi`5D - profic Viency`5Bi`5D; X end; X end; X X procedure hack_class_stats; X begin X with class`5Bpl`5Bnow`5D.attrib_ex`5Bst_class`5D`5D do X begin X for i := 1 to at_max do X if not (human and (i in `5Bat_wealth,at_points`5D)) then X begin X`09pl`5Bnow`5D.attrib`5Bi`5D := pl`5Bnow`5D.attrib`5Bi`5D - attrib`5Bi`5D; X`09pl`5Bnow`5D.attrib_max`5Bi`5D := pl`5Bnow`5D.attrib_max`5Bi`5D - attrib`5 VBi`5D; X end; X for i := 1 to el_max do X `09pl`5Bnow`5D.proficiency`5Bi`5D := pl`5Bnow`5D.proficiency`5Bi`5D - prof Viciency`5Bi`5D; X end; X end; X X procedure hack_condition_stats; X begin X for i := 1 to ps_max do X if pl`5Bnow`5D.sts`5Bi`5D.on then X pl`5Bnow`5D.sts`5Bi`5D.time := pl`5Bnow`5D.sts`5Bi`5D.time - getticks; X end; X Xbegin X hack_race_stats; X hack_class_stats; X hack_condition_stats; X unequip_stats(false); Xend; X X`5Basynchronous`5D Xprocedure save_player; Xvar X i:integer; Xbegin X hack_stats; X getplayer(plr`5Bnow`5D.log); X player := pl`5Bnow`5D; X putplayer; X stats; Xend; X X`5Basynchronous`5D Xprocedure readnames; Xvar X i:integer; Xbegin X for i := 1 to na_max do X begin X getname(i); X freename; X end; Xend; X Xprocedure readints; Xvar X i:integer; Xbegin X for i := 1 to n_max do X begin X getint(i); X freeint; X end; Xend; X Xprocedure readindexes; Xvar X i:integer; Xbegin X for i := 1 to i_max do X begin X getindex(i); X freeindex; X end; Xend; X X`5Basynchronous`5D Xprocedure unwho_prime(lognum:integer; echo:boolean); Xbegin X wl('It appears '+name`5Bna_player`5D.id`5Blognum`5D+' was stackdumped.',ec Vho); X getindex(i_ingame); X indx`5Bi_ingame`5D.on`5Blognum`5D := false; X putindex(i_ingame); Xend; X X`5Basynchronous`5D Xprocedure remove_player(log:integer; echo:boolean := false; X`09`09`09unwho:boolean := true); Xbegin X deassign_channel(person`5Blog`5D.channel); X if person`5Blog`5D.here then unplot_player(log); X if unwho then unwho_prime(log,echo); X if window_name = 'Who list' then remove_x(name`5Bna_player`5D.id`5Blog`5D) V; X indx`5Bi_ingame`5D.on`5Blog`5D := false; X person`5Blog`5D.here := false; Xend; X X`5Basynchronous`5D Xfunction empty_room:boolean; Xvar X i:integer; Xbegin X empty_room := true; X for i := 1 to maxplayers do X if person`5Bi`5D.here and (not indx`5Bi_npc`5D.on`5Bi`5D) then empty_room V := false; Xend; X X`5Bglobal,asynchronous`5D Xfunction ping(lognum:integer):boolean; X`7BReturns value of pong`7D Xvar X dummy,ok:boolean; Xbegin X writev(qpqp,'Ping ',lognum); X bug_out(qpqp); X ping := false; X if human then ok := (lognum <> plr`5Bnow`5D.log) X else ok := (not indx`5Bi_npc`5D.on`5Blognum`5D) and X (an_int`5Bn_location`5D.int`5Blognum`5D = here.valid); X if ok then X begin X dummy := person`5Blognum`5D.here; X person`5Blognum`5D.here := false; X act_out(0,e_ping,lognum,mychannel); X wait(3); X if not person`5Blognum`5D.here then X begin X remove_player(lognum,true,human); X if (not human) then X if empty_room then all_done := true; X end X else X begin X ping := true; X wl(name`5Bna_player`5D.id`5Blognum`5D+' has ponged.'); X person`5Blognum`5D.here := dummy; X end; X end; X bug_out('End ping!'); Xend; X X`5Basynchronous`5D Xfunction do_mask(b1:boolean := true; m1:integer := 0; X`09`09 b2:boolean := true; m2:integer := 0; X`09`09 b3:boolean := true; m3:integer := 0; X`09`09 b4:boolean := true; m4:integer := 0):integer; Xvar X mask_sum:integer := 0; Xbegin X if b1 then mask_sum := mask_sum + m1; X if b2 then mask_sum := mask_sum + m2; X if b3 then mask_sum := mask_sum + m3; X if b4 then mask_sum := mask_sum + m4; X do_mask := mask_sum; Xend; X Xprocedure assign_channels; X`7BAssigns channels to all the non-npc people in the game`7D Xvar X i,mylog:integer; X npc_done:boolean := false; Xbegin X if now = 0 then mylog := 0 X else mylog := plr`5Bnow`5D.log; X for i := 1 to maxplayers do X if (indx`5Bi_ingame`5D.on`5Bi`5D) and (i <> mylog) and (not indx`5Bi_npc`5 VD.on`5Bi`5D) then X begin X getplayer(i); X freeplayer; X if human then X begin X if assign_channel(player.mbx,person`5Bi`5D.channel) then X`09act_out(plr`5Bnow`5D.log,e_assign,,, X`09do_mask(first_time,m_first_in),,,,mymbx, X`09name`5Bna_player`5D.id`5Bplr`5Bnow`5D.log`5D,,person`5Bi`5D.channel) X`09else ping(i); X end X else X if (an_int`5Bn_location`5D.int`5Bi`5D = here.valid) then X begin X if assign_channel(player.mbx,person`5Bi`5D.channel) then X act_out(,e_assign,,,,here.valid,,,mymbx,,,person`5Bi`5D.channel) X else ping(i); X end; X end; Xend; X Xprocedure deassign_channels; Xvar X i:integer; Xbegin X getindex(i_ingame); X freeindex; X for i := 1 to maxplayers do X if (indx`5Bi_ingame`5D.on`5Bi`5D) then deassign_channel(person`5Bi`5D.chan Vnel); Xend; X Xprocedure addrooms(n:integer); Xvar X i:integer; Xbegin X getindex(i_room); X for i := indx`5Bi_room`5D.top + 1 to indx`5Bi_room`5D.top + n do X begin X locate(roomfile,i); X roomfile`5E.valid := i; X put(roomfile); X locate(fgfile,i); X fgfile`5E.valid := i; X put(fgfile); X end; X indx`5Bi_room`5D.top := indx`5Bi_room`5D.top + n; X putindex(i_room); Xend; X Xprocedure addobjects(n:integer); Xvar X i:integer; Xbegin X getindex(i_object); X for i := indx`5Bi_object`5D.top + 1 to indx`5Bi_object`5D.top + n do X begin X locate(objfile,i); X objfile`5E.valid := i; X put(objfile); X end; X indx`5Bi_object`5D.top := indx`5Bi_object`5D.top + n; X putindex(i_object); Xend; X Xprocedure addspells(n:integer); Xvar X i:integer; Xbegin X getindex(i_spell); X for i := indx`5Bi_spell`5D.top + 1 to indx`5Bi_spell`5D.top + n do X begin X locate(spellfile,i); X spellfile`5E.valid := i; X put(spellfile); X end; X indx`5Bi_spell`5D.top := indx`5Bi_spell`5D.top + n; X putindex(i_spell); Xend; X Xprocedure addraces(n:integer); Xvar X i:integer; Xbegin X getindex(i_race); X for i := indx`5Bi_race`5D.top + 1 to indx`5Bi_race`5D.top + n do X begin X locate(racefile,i); X racefile`5E.valid := i; X put(racefile); X end; X indx`5Bi_race`5D.top := indx`5Bi_race`5D.top + n; X putindex(i_race); Xend; X Xprocedure addplayers(n:integer; npc:boolean := false); Xvar X i,j:integer; Xbegin X getindex(i_player); X getindex(i_npc); X getindex(i_ingame); X for i := indx`5Bi_player`5D.top + 1 to indx`5Bi_player`5D.top + n do X begin X indx`5Bi_ingame`5D.on`5Bi`5D := false; X indx`5Bi_player`5D.on`5Bi`5D := npc; X indx`5Bi_npc`5D.on`5Bi`5D := npc; X locate(playerfile,i); X with playerfile`5E do X begin X valid := i; X for j := 1 to maxspell do spell`5Bj`5D := false; X for j := 1 to at_max do X begin X`09attrib`5Bj`5D := 0; X attrib_max`5Bj`5D := 0; X end; X attrib_ex`5Bst_class`5D := 1; X attrib_ex`5Bst_race`5D := 1; X attrib_ex`5Bst_kills`5D := 1; X attrib_ex`5Bst_killed`5D := 1; X where.x := 1; X where.y := 1; +-+-+-+-+-+-+-+- END OF PART 12 +-+-+-+-+-+-+-+-