소스 분석좀 부탁드릴께요..

프로그래밍 일반에 관한 포럼입니다.

Moderator: 류광

Locked
chorahan
Posts: 2
Joined: 2005-05-25 22:05

소스 분석좀 부탁드릴께요..

Post by chorahan »

좀 긴거라서 죄송하지만..ㅠㅠ;;

한글로 차근차근 설명 좀 해주세요..

가뜩이나 잘 모르겠는게 대부분인데..

주석까지 영문(당연하지만..-_-)이라서..끄응..



#include "uox3.h"
#include "debug.h"

#define DBGFILE "magic.cpp"
//:Terrin: added constructor/destructor
cMagic::cMagic()
{
// it would be nice to go ahead and cache them now, but the
// script files won't have been loaded yet..
spells = NULL;
}

cMagic::~cMagic()
{
// delete any allocations
if (spells)
delete [] spells;
}
//o---------------------------------------------------------------------------o
//| Class : ::SpellBook( UOXSOCKET s )
//| Date : Unknown
//| Programmer : Unknown
//o---------------------------------------------------------------------------o
//| Purpose : Sends the spellbook item (with all the
//| memorized spells) to player when
//| doubleclicked.
//o---------------------------------------------------------------------------o

void cMagic::SpellBook( UOXSOCKET s )
{
int i, j, scount, item, x,serial,serhash,ci;
int spellsList[70];
char sbookstart[8]="\x24\x40\x01\x02\x03\xFF\xFF";
char sbookinit[6]="\x3C\x00\x3E\x00\x03";
char sbookspell[20]="\x40\x01\x02\x03\x1F\x2E\x00\x00\x01\x00\x48\x00\x7D\x40\x01\x02\x03\x00\x00";

serial=calcserial(buffer[s][1]&0x7F,buffer[s][2],buffer[s][3],buffer[s][4]);
item=findbyserial(&itemsp[serial%HASHMAX],serial,0);

x=packitem(currchar[s]);
if (item!=-1 && x!=-1) //lb
if (items[item].contserial!=items[x].serial && items[item].contserial!=chars[currchar[s]].serial)
{
if( items[findbyserial(&itemsp[items[item].contserial%HASHMAX], items[item].contserial, 0 )].type != 9 )
{
sysmessage(s, "In order to open spellbook, it must be equipped in your hand or in the first layer of your backpack.");
}
return;
}

if (item==-1)
{
item=-1;
if (x!=-1)
{
serial=items[x].serial;
serhash=serial%HASHMAX;

// AntiChrist Fix -- itemcount loop removed by LB

for (ci=0;ci<contsp[serhash].max;ci++)
{
i=contsp[serhash].pointer[ci];
if (i!=-1)
if (((items.type==9)&&(items.contserial==serial)))
{
item=i;
break;
}
}
}
}
// LB remark: If you want more than one spellbook per player working predictable
// quite a lot of that function needs to be rewritten !
// reason: just have a look at the loop above ...

if (item==-1)
{
serial=chars[currchar[s]].serial;
serhash=serial%HASHMAX;
for (ci=0;ci<contsp[serhash].max;ci++)
{
i=contsp[serhash].pointer[ci];
if (i!=-1)
if ((items.contserial==serial) && (items.free==0))
{
if ((items.layer==1) && items.type==9)
{
item=i;
break;
}
}
}
}

if (item==-1)
{
sysmessage(s, "In order to open spellbook, it must be equipped in your hand or in the first layer of your backpack.");
return;
}


if (items[item].layer!=1) senditem(s,item); // prevents crash if pack not open

// Network->xSend(s, pause, 2, 0);
sbookstart[1]=items[item].ser1;
sbookstart[2]=items[item].ser2;
sbookstart[3]=items[item].ser3;
sbookstart[4]=items[item].ser4;
Network->xSend(s, sbookstart, 7, 0);
scount=0;
for (i=0;i<70;i++)
{
spellsList=0;
}

serial=items[item].serial;
serhash=serial%HASHMAX;
for (ci=0;ci<contsp[serhash].max;ci++)
{
j=contsp[serhash].pointer[ci];
if (j!=-1)
if ((items[j].contserial==serial))
{
if (items[j].id1==0x1F && items[j].id2>=0x2D && items[j].id2<=0x72)
{
spellsList[items[j].id2-0x2D]=1;
}
}
}

// Fix for Reactive Armor/Bird's Eye dumbness. :)
i=spellsList[0];
spellsList[0]=spellsList[1];
spellsList[1]=spellsList[2];
spellsList[2]=spellsList[3];
spellsList[3]=spellsList[4];
spellsList[4]=spellsList[5];
spellsList[5]=spellsList[6]; // Morac is right! :)
spellsList[6]=i;
// End fix.

if (spellsList[64])
{
for (i=0;i<70;i++)
spellsList=1;
spellsList[64]=0;
}
spellsList[64]=spellsList[65];
spellsList[65]=0;

for (i=0;i<70;i++)
{
if (spellsList) scount++;
}
sbookinit[1]=((scount*19)+5)>>8;
sbookinit[2]=((scount*19)+5)%256;
sbookinit[3]=scount>>8;
sbookinit[4]=scount%256;
if (scount>0) Network->xSend(s, sbookinit, 5, 0);
for (i=0;i<70;i++)
{
if (spellsList)
{
sbookspell[0]=0x41;
sbookspell[1]=0x00;
sbookspell[2]=0x00;
sbookspell[3]=i+1;
sbookspell[8]=i+1;
sbookspell[13]=items[item].ser1;
sbookspell[14]=items[item].ser2;
sbookspell[15]=items[item].ser3;
sbookspell[16]=items[item].ser4;
Network->xSend(s, sbookspell, 19, 0);
}
// Network->xSend(s, restart, 2, 0);
}
}
비회원

아니.. gpgstudy에 이런것이?!

Post by 비회원 »

이건 울티마온라인 프리서버에뮬레이터의 모듈파일... -_-
c언어 공부나 하시지. 이런걸 여기에 올리고 싶으세요?
Locked