안시 사용하기
2007.04.12 12:27
print 함수에 약간 추가를 해서.. 만든 printa 함수입니다.
모든 print 함수를 printa 로 바꾸면 100% 다운이 돼고.. ^^;
안시를 사용하려고 하는 부분에서만..
print 함수를 printa 로 바꿔주시면 돼요.
void printa(fd, fmt, i1, i2, i3, i4, i5, i6, i7, i8)
int fd;
unsigned char *fmt;
int i1, i2, i3, i4, i5, i6, i7, i8;
{
char msg[3072];
char *fmt2;
char fmt3[256], temp[80];
int i = 0, j = 0, k, n, otail, ohead, c, mmm;
int num, loc=0, ind = -1, len, flags = 0;
int arg[10];
char type=0;
char *prestr=0;
char *Josa[6][2]={ {"은","는",},{"이","가",},{"과","와",},{"을","를",},{"으로","로",},};
static char color_buf1[16];
static char color_buf2[16];
if(fd == -1 || fd > Tablesize)
return;
if(!Ply[fd].io)
return;
if(Ply[fd].ply) {
if(F_ISSET(Ply[fd].ply, PDINVI))
flags |= INV;
if(Ply[fd].ply->class>=DM)
flags |= DMF;
}
i = 0; j = 0;
len = strlen(fmt);
fmt2 = (char *)malloc(len+1);
if(!fmt2)
merror("print", FATAL);
arg[0] = i1; arg[1] = i2; arg[2] = i3;
arg[3] = i4; arg[4] = i5; arg[5] = i6;
arg[6] = i7; arg[7] = i8;
/* Check for %m, %M, %i and %I and modify arguments as necessary */
do {
if(fmt[i] == '%') {
fmt2[j++] = fmt[i];
num = 0; k = i;
do {
k++;
if((fmt[k] >= 'a' && fmt[k] <= 'z') ||
(fmt[k] >= 'A' && fmt[k] <= 'Z') ||
fmt[k] == '%') {
loc = k;
type = fmt[k];
break;
}
else if(fmt[k] >= '0' && fmt[k] <= '9')
num = num*10 + fmt[k]-'0';
} while(k < len);
if(type == '%') {
fmt2[j++] = '%';
i++; i++;
continue;
}
ind++;
if(type != 'm' && type != 'M' && type != 'j' && type != 'A' &&
type != 'i' && type != 'I' && type !='S' && type !='D' && type!='C') {
i++;
continue;
}
i = loc + 1;
fmt2[j++] = 's';
switch(type) {
case 'm':
arg[ind] = (int)(prestr=crt_str(arg[ind], num, flags|CAP));
continue;
case 'M':
arg[ind] = (int)(prestr=crt_str(arg[ind], num, flags));
continue;
case 'S':
prestr=(char *)arg[ind];
continue;
case 'j':
switch(*((char *)arg[ind])) {
case '0':
case '1':
case '2':
case '3':
case '4':
if(under_han(prestr)) arg[ind]=(int)Josa[*((char *)arg[ind])-'0'][0];
else arg[ind] = (int)Josa[*((char *)arg[ind])-'0'][1];
break;
default: arg[ind]= (int)"";
}
continue;
case 'i':
case 'I':
arg[ind] = (int)(prestr=obj_str(arg[ind], num, flags));
continue;
case 'C':
if(F_ISSET(Ply[fd].ply,PANSIC)) {
sprintf(color_buf1,"%c[%d;%sm",27,
(F_ISSET(Ply[fd].ply,PBRIGH)&&atoi((char *)arg[ind])!=WHITE)?1:0,
(char *)arg[ind]);
arg[ind]=(int)color_buf1;
} else arg[ind]= (int)"";
continue;
case 'A':
if(F_ISSET(Ply[fd].ply,PANSIC)) {
sprintf(color_buf1,"%c[%d;%dm",27,
(F_ISSET(Ply[fd].ply,PBRIGH)&&arg[ind]!=WHITE)?1:0,
arg[ind]);
arg[ind]=(int)color_buf1;
} else arg[ind]= (int)"";
continue;
case 'D':
if(F_ISSET(Ply[fd].ply,PANSIC)) {
sprintf(color_buf2,"%c[%d;%sm",27,
(F_ISSET(Ply[fd].ply,PBRIGH)&&atoi((char *)arg[ind])!=WHITE)?1:0,
(char *)arg[ind]);
arg[ind]=(int)color_buf2;
} else arg[ind]= (int)"";
continue;
}
}
fmt2[j++] = fmt[i++];
} while (i < len);
fmt2[j] = 0;
sprintf(msg, fmt2, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7]);
free(fmt2);
i = 0; j = 0;
len = strlen(msg);
fmt3[0] = 0;
for(mmm=0; mmm < len; mmm++) {
if(msg[mmm] == '{') {
if((c = color_cmp(msg+mmm+1)) != 0) {
if(F_ISSET(Ply[fd].ply,PANSIC)) {
sprintf(temp,"%c[%d;%dm",27,
F_ISSET(Ply[fd].ply,PBRIGH)?1:0, c);
sprintf(fmt3+j, "%s", temp);
j += strlen(temp);
}
mmm += 2;
continue;
}
else {
fmt3[j] = '{';
j++;
}
}
else if(msg[mmm]=='}') {
temp[0] = 0;
if(F_ISSET(Ply[fd].ply,PANSIC))
sprintf(temp,"%c[0;37m%c[0;0m",27,27);
sprintf(fmt3+j, "%s", temp);
j += strlen(temp);
}
else {
fmt3[j] = msg[mmm];
j++;
}
}
if(F_ISSET(Ply[fd].ply,PANSIC))
sprintf(fmt3+j,"%c[0;37m%c[0;0m",27,27);
else
fmt3[j] = 0;
n = strlen(fmt3);
/*
if(n > 78 && title_cut_index[fd]==0) {
delimit(fmt3);
n = strlen(fmt3);
}
*/
ohead = Ply[fd].io->ohead;
otail = Ply[fd].io->otail;
for(i=0; i Ply[fd].io->output[ohead] = fmt3[i];
if(fmt3[i]=='\n') {
Ply[fd].io->output[ohead] = '\r';
ohead = (ohead + 1) % OBUFSIZE;
if(ohead == otail)
otail = (otail + 1) % OBUFSIZE;
Ply[fd].io->output[ohead] = fmt3[i];
}
ohead = (ohead + 1) % OBUFSIZE;
if(ohead == otail)
otail = (otail + 1) % OBUFSIZE;
}
Ply[fd].io->ohead = ohead;
Ply[fd].io->otail = otail;
}
print 함수에 몇줄 더 추가된거 뿐이에요.
소스상에서 사용하는 방법은..
printa(fd, "{빨당신은 죽었습니다.}");
이런식으로 소스상에서 나오는 말들도 고쳐줄수 있고..
말.. 등에서.. print 사용하는 부분을.. printa 로 바꿔주면..
사용자가 말하는데서 안시 사용가능해요.
만약 물건이름이나 몹이름에 안시를 사용하려고 한다면..
%M %I %m %i 이런거 들어간 print 함수를 전부 printa 로 바꿔주고.
아이템 이름을.. {파천신의 {노방패} <-- 이런식으로 만들면 돼죠.
고치려면.. 약간은 노가다가 필요한 방법이고..
print 함수에서 한번 더 변환 과정을 거치기 땜에..
속도에 약간 문제가 생길수 있어요.
홈지기 "그륨"
모든 print 함수를 printa 로 바꾸면 100% 다운이 돼고.. ^^;
안시를 사용하려고 하는 부분에서만..
print 함수를 printa 로 바꿔주시면 돼요.
void printa(fd, fmt, i1, i2, i3, i4, i5, i6, i7, i8)
int fd;
unsigned char *fmt;
int i1, i2, i3, i4, i5, i6, i7, i8;
{
char msg[3072];
char *fmt2;
char fmt3[256], temp[80];
int i = 0, j = 0, k, n, otail, ohead, c, mmm;
int num, loc=0, ind = -1, len, flags = 0;
int arg[10];
char type=0;
char *prestr=0;
char *Josa[6][2]={ {"은","는",},{"이","가",},{"과","와",},{"을","를",},{"으로","로",},};
static char color_buf1[16];
static char color_buf2[16];
if(fd == -1 || fd > Tablesize)
return;
if(!Ply[fd].io)
return;
if(Ply[fd].ply) {
if(F_ISSET(Ply[fd].ply, PDINVI))
flags |= INV;
if(Ply[fd].ply->class>=DM)
flags |= DMF;
}
i = 0; j = 0;
len = strlen(fmt);
fmt2 = (char *)malloc(len+1);
if(!fmt2)
merror("print", FATAL);
arg[0] = i1; arg[1] = i2; arg[2] = i3;
arg[3] = i4; arg[4] = i5; arg[5] = i6;
arg[6] = i7; arg[7] = i8;
/* Check for %m, %M, %i and %I and modify arguments as necessary */
do {
if(fmt[i] == '%') {
fmt2[j++] = fmt[i];
num = 0; k = i;
do {
k++;
if((fmt[k] >= 'a' && fmt[k] <= 'z') ||
(fmt[k] >= 'A' && fmt[k] <= 'Z') ||
fmt[k] == '%') {
loc = k;
type = fmt[k];
break;
}
else if(fmt[k] >= '0' && fmt[k] <= '9')
num = num*10 + fmt[k]-'0';
} while(k < len);
if(type == '%') {
fmt2[j++] = '%';
i++; i++;
continue;
}
ind++;
if(type != 'm' && type != 'M' && type != 'j' && type != 'A' &&
type != 'i' && type != 'I' && type !='S' && type !='D' && type!='C') {
i++;
continue;
}
i = loc + 1;
fmt2[j++] = 's';
switch(type) {
case 'm':
arg[ind] = (int)(prestr=crt_str(arg[ind], num, flags|CAP));
continue;
case 'M':
arg[ind] = (int)(prestr=crt_str(arg[ind], num, flags));
continue;
case 'S':
prestr=(char *)arg[ind];
continue;
case 'j':
switch(*((char *)arg[ind])) {
case '0':
case '1':
case '2':
case '3':
case '4':
if(under_han(prestr)) arg[ind]=(int)Josa[*((char *)arg[ind])-'0'][0];
else arg[ind] = (int)Josa[*((char *)arg[ind])-'0'][1];
break;
default: arg[ind]= (int)"";
}
continue;
case 'i':
case 'I':
arg[ind] = (int)(prestr=obj_str(arg[ind], num, flags));
continue;
case 'C':
if(F_ISSET(Ply[fd].ply,PANSIC)) {
sprintf(color_buf1,"%c[%d;%sm",27,
(F_ISSET(Ply[fd].ply,PBRIGH)&&atoi((char *)arg[ind])!=WHITE)?1:0,
(char *)arg[ind]);
arg[ind]=(int)color_buf1;
} else arg[ind]= (int)"";
continue;
case 'A':
if(F_ISSET(Ply[fd].ply,PANSIC)) {
sprintf(color_buf1,"%c[%d;%dm",27,
(F_ISSET(Ply[fd].ply,PBRIGH)&&arg[ind]!=WHITE)?1:0,
arg[ind]);
arg[ind]=(int)color_buf1;
} else arg[ind]= (int)"";
continue;
case 'D':
if(F_ISSET(Ply[fd].ply,PANSIC)) {
sprintf(color_buf2,"%c[%d;%sm",27,
(F_ISSET(Ply[fd].ply,PBRIGH)&&atoi((char *)arg[ind])!=WHITE)?1:0,
(char *)arg[ind]);
arg[ind]=(int)color_buf2;
} else arg[ind]= (int)"";
continue;
}
}
fmt2[j++] = fmt[i++];
} while (i < len);
fmt2[j] = 0;
sprintf(msg, fmt2, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7]);
free(fmt2);
i = 0; j = 0;
len = strlen(msg);
fmt3[0] = 0;
for(mmm=0; mmm < len; mmm++) {
if(msg[mmm] == '{') {
if((c = color_cmp(msg+mmm+1)) != 0) {
if(F_ISSET(Ply[fd].ply,PANSIC)) {
sprintf(temp,"%c[%d;%dm",27,
F_ISSET(Ply[fd].ply,PBRIGH)?1:0, c);
sprintf(fmt3+j, "%s", temp);
j += strlen(temp);
}
mmm += 2;
continue;
}
else {
fmt3[j] = '{';
j++;
}
}
else if(msg[mmm]=='}') {
temp[0] = 0;
if(F_ISSET(Ply[fd].ply,PANSIC))
sprintf(temp,"%c[0;37m%c[0;0m",27,27);
sprintf(fmt3+j, "%s", temp);
j += strlen(temp);
}
else {
fmt3[j] = msg[mmm];
j++;
}
}
if(F_ISSET(Ply[fd].ply,PANSIC))
sprintf(fmt3+j,"%c[0;37m%c[0;0m",27,27);
else
fmt3[j] = 0;
n = strlen(fmt3);
/*
if(n > 78 && title_cut_index[fd]==0) {
delimit(fmt3);
n = strlen(fmt3);
}
*/
ohead = Ply[fd].io->ohead;
otail = Ply[fd].io->otail;
for(i=0; i Ply[fd].io->output[ohead] = fmt3[i];
if(fmt3[i]=='\n') {
Ply[fd].io->output[ohead] = '\r';
ohead = (ohead + 1) % OBUFSIZE;
if(ohead == otail)
otail = (otail + 1) % OBUFSIZE;
Ply[fd].io->output[ohead] = fmt3[i];
}
ohead = (ohead + 1) % OBUFSIZE;
if(ohead == otail)
otail = (otail + 1) % OBUFSIZE;
}
Ply[fd].io->ohead = ohead;
Ply[fd].io->otail = otail;
}
print 함수에 몇줄 더 추가된거 뿐이에요.
소스상에서 사용하는 방법은..
printa(fd, "{빨당신은 죽었습니다.}");
이런식으로 소스상에서 나오는 말들도 고쳐줄수 있고..
말.. 등에서.. print 사용하는 부분을.. printa 로 바꿔주면..
사용자가 말하는데서 안시 사용가능해요.
만약 물건이름이나 몹이름에 안시를 사용하려고 한다면..
%M %I %m %i 이런거 들어간 print 함수를 전부 printa 로 바꿔주고.
아이템 이름을.. {파천신의 {노방패} <-- 이런식으로 만들면 돼죠.
고치려면.. 약간은 노가다가 필요한 방법이고..
print 함수에서 한번 더 변환 과정을 거치기 땜에..
속도에 약간 문제가 생길수 있어요.
홈지기 "그륨"
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
17 | 프롬프트 그래프화 #2 | 그리움 | 2007.04.12 | 280 |
16 | 낚시 | 그리움 | 2007.04.12 | 280 |
15 | 운영자명령 "보고" | 그리움 | 2007.04.12 | 280 |
14 | 이동하는 몹 | 그리움 | 2007.04.12 | 283 |
13 | 머드에서 몹 심기 | 그리움 | 2007.04.12 | 287 |
12 | 온라인 리붓 | 그리움 | 2007.04.12 | 287 |
11 | 방전체 공격루틴 #2 | 그리움 | 2007.04.12 | 287 |
10 | 개척 소스 | 그리움 | 2007.04.12 | 302 |
9 | 감옥/퇴소 | 그리움 | 2007.04.12 | 338 |
8 | 물건, 몹의 번호 찾아내기. | 그리움 | 2007.07.04 | 392 |
7 | 몹 소환하여 소환몹이 대신 싸우게 하기 | 그리움 | 2007.11.23 | 398 |
6 | 주민등록번호 검사 소스 | 그리움 | 2007.04.12 | 420 |
5 | 무한대전 방 데이터 Convert | 그리움 | 2007.11.23 | 423 |
4 | 연타기능 - 연타수 자동 | 그리움 | 2007.04.12 | 447 |
3 | 게시판 버그 해결 방법. | 그리움 | 2007.04.12 | 470 |
2 | 연타기능 - 직업별 연타 | 그리움 | 2007.04.12 | 479 |
1 | *괴물이름 방폭 버그 수정 | 그리움 | 2007.04.12 | 533 |