Constraint_list *prepare_cl_for_moca ( Constraint_list *CL) { int a, b, c; int tot_l, l; char **name, **seq; Sequence *NS=NULL; /*Prepare the constraint list*/ CL->do_self=1; CL->get_dp_cost=moca_slow_get_dp_cost; CL->evaluate_residue_pair=moca_residue_pair_extended_list; /*Prepare the moca parameters*/ (CL->moca)->evaluate_domain=evaluate_moca_domain; (CL->moca)->cache_cl_with_domain=cache_cl_with_moca_domain; (CL->moca)->make_nol_aln=make_moca_nol_aln; /*Prepare the packing of the sequences*/ for ( a=0, b=1; a< (CL->S)->nseq; a++)b+=strlen ( (CL->S)->seq[a])+1; seq =declare_char ( 1,b+1); name=declare_char( 1,30); CL->packed_seq_lu =declare_int ( b, 2); for (tot_l=1,a=0; a< (CL->S)->nseq; a++) { strcat (seq[0], (CL->S)->seq[a]); strcat (seq[0], "X"); l=strlen((CL->S)->seq[a]); for ( c=1; c<= l; c++, tot_l++) { CL->packed_seq_lu[tot_l][0]=a; CL->packed_seq_lu[tot_l][1]=c; } CL->packed_seq_lu[tot_l++][0]=UNDEFINED; } sprintf ( name[0], "catseq"); NS=fill_sequence_struc(1, seq, name, NULL); CL->S=add_sequence (NS, CL->S, 0); free_char( seq, -1); free_char(name, -1); free_sequence (NS, NS->nseq); return CL; }
Alignment *free_data_in_aln (Alignment *A) { //Frees only the sequence data (keeps profile information) A->seq_al=free_char (A->seq_al, -1); A->seq_comment=free_char (A->seq_comment, -1); A->aln_comment=free_char (A->aln_comment, -1); A->name=free_char (A->name, -1); A->expanded_order=free_char (A->expanded_order, -1); A->order=free_int (A->order, -1); A->seq_cache=free_int (A->seq_cache, -1); A->cdna_cache=free_int (A->cdna_cache, -1); A->score_res=free_int (A->score_res, -1); free_sequence (A->S, -1); A->S=NULL; return A; }
int *code_seq (char *seq, char *type) { static int *code; static int *aa, ng; int a, b, l; if (!aa) { char **gl; if ( strm (type, "DNA") || strm (type, "RNA")) { gl=declare_char (4,5); sprintf ( gl[ng++], "Aa"); sprintf ( gl[ng++], "Gg"); sprintf ( gl[ng++], "TtUu"); sprintf ( gl[ng++], "Cc"); } else { gl=make_group_aa ( &ng, "mafft"); } aa=(int*)vcalloc ( 256, sizeof (int)); for ( a=0; a<ng; a++) { for ( b=0; b< strlen (gl[a]); b++) { aa[(int)gl[a][b]]=a; } } free_char (gl, -1); } l=strlen (seq); if ( code) code--; if ( !code || read_array_size (code, sizeof (int))<(l+2)) { vfree (code); code=(int*)vcalloc (l+2, sizeof (int)); } code[0]=ng; code++; for (a=0; a<l; a++) { code[a]=aa[(int)seq[a]]; } code[a]=END_ARRAY; return code; }
Sequence* free_Alignment ( Alignment *LA) { /* Does not free the A->S field (sequences of A)*/ Sequence *S; //aln_stack checks the alignment has not already been freed if ( LA==NULL || !aln_stack(LA,FREE_ALN)){return NULL;} S=LA->S; free_char ( LA->file, -1); free_char ( LA->seq_al, -1); free_int ( LA->seq_cache, -1); free_int ( LA->cdna_cache, -1); free_char ( LA->name,-1); free_char ( LA->tree_order,-1); vfree ( LA->generic_comment); free_char ( LA->seq_comment, -1); free_char ( LA->aln_comment, -1); free_int ( LA->order, -1); vfree ( LA->score_seq); vfree ( LA->len); free_profile (LA->P); if ( LA->A){free_Alignment (LA->A);LA->A=NULL;} vfree ( LA); return S; }
void free_sequence ( Sequence *LS, int nseq) { if ( !LS) return; free_char ( LS->file, -1); free_char ( LS->seq_comment, -1); free_char ( LS->aln_comment, -1); free_char ( LS->seq, -1); free_char ( LS->name,-1); free_int (LS->dc, -1); free_arrayN((void*)LS->T, 2); vfree (LS->type); vfree (LS->len); free_weights (LS->W); //Don't free LS->blastdb; vfree (LS); }
/* usun arty ktorym uplynela zywotnosc z postaci o imieniu name */ void remove_artefact_art_destroy( char *name ) { CHAR_DATA * ch; ch = load_char_remote( name ); /* je¿eli 'ch' nie istnieje */ if ( !ch ) { char buf[MSL]; sprintf(buf, "%s: brak pliku postaci %s", __func__, name ); log_string( buf ); return; } save_char_obj( ch, FALSE, TRUE ); free_char( ch ); }
Weights* free_weights ( Weights* W) { if ( !W)return NULL; vfree(W->comments); vfree(W->mode); free_char(W->seq_name, -1); free_float(W->PW_SD,-1); free_float(W->PW_ID, -1); vfree(W->SEQ_W); vfree(W); return NULL; }
int open_window( GlobalFunc *global ) { int i; natorder = native_order(); msgf = global( LWMESSAGEFUNCS_GLOBAL, GFUSE_TRANSIENT ); filereq = global( LWFILEREQFUNC_GLOBAL, GFUSE_TRANSIENT ); rasf = global( LWRASTERFUNCS_GLOBAL, GFUSE_TRANSIENT ); panf = global( LWPANELFUNCS_GLOBAL, GFUSE_TRANSIENT ); if ( !msgf || !filereq || !rasf || !panf ) return AFUNC_BADGLOBAL; panf->globalFun = global; if( !( panel = PAN_CREATE( panf, PANEL_TITLE ))) { msgf->error( PLUGIN_NAME " couldn't create its panel,", "not sure why." ); return AFUNC_OK; } panf->set( panel, PAN_USERKEYS, handle_key ); panf->set( panel, PAN_USEROPEN, handle_panopen ); cras[ 0 ] = create_char( COLOR_WHITE, SYSTEM_Ic( 30 ), rasf ); cras[ 1 ] = create_char( COLOR_BLACK, SYSTEM_Ic( 2 ), rasf ); cras[ 2 ] = create_char( COLOR_BLACK, SYSTEM_Ic( 15 ), rasf ); create_controls(); panf->open( panel, PANF_BLOCKING ); PAN_KILL( panf, panel ); for ( i = 0; i < 3; i++ ) free_char( cras[ i ], rasf ); free_icon( rasf ); return AFUNC_OK; }
/* Extract a ch completely from the world, and leave his stuff behind */ void extract_char(struct char_data *ch, bool pull) { struct obj_data *obj; struct char_data *k, *next_char; struct descriptor_data *t_desc; int l, was_in; extern struct char_data *combat_list; void die_follower(struct char_data *ch); if ( !IS_NPC(ch) && !ch->desc ) { for ( t_desc = descriptor_list; t_desc; t_desc = t_desc->next ) { if ( t_desc->original == ch ) do_return( t_desc->character, "", 0 ); } } if ( ch->in_room == NOWHERE ) { log( "Extract_char: NOWHERE" ); exit( 1 ); } if ( ch->followers || ch->master ) die_follower(ch); while ( ( obj = ch->carrying ) != NULL ) { obj_from_char( obj ); obj_to_room( obj, ch->in_room ); } if ( ch->specials.fighting ) stop_fighting( ch ); for ( k = combat_list; k ; k = next_char ) { next_char = k->next_fighting; if ( k->specials.fighting == ch ) stop_fighting( k ); } /* Must remove from room before removing the equipment! */ was_in = ch->in_room; char_from_room( ch ); if ( !pull ) char_to_room(ch, real_room(3001)); /* clear equipment_list */ for ( l = 0; l < MAX_WEAR; l++ ) { if ( ch->equipment[l] ) obj_to_room(unequip_char(ch,l), was_in); } GET_AC(ch) = 100; if ( ch->desc && ch->desc->original ) do_return( ch, "", 0 ); if ( IS_NPC(ch) && ch->nr > -1 ) mob_index[ch->nr].number--; if ( pull ) { if ( ch == character_list ) character_list = ch->next; else { for ( k = character_list; k && k->next != ch; k = k->next ) ; if ( k ) k->next = ch->next; else { log( "Extract_char: bad char list" ); abort(); } } free_char( ch ); } }
void do_finger( CHAR_DATA *ch, char *argument ) { char arg[MAX_INPUT_LENGTH]; char buf[MAX_STRING_LENGTH]; CHAR_DATA *victim; FILE *fp; bool fOld; one_argument( argument, arg ); if ( arg[0] == '\0' ) { send_to_char( "Finger whom?\n\r", ch ); return; } if ( ( victim = get_char_world( ch, arg ) ) != NULL) { if (!IS_NPC(victim)) { act( "$N is on right now!", ch, NULL, victim, TO_CHAR ); return; } } victim = new_char(); victim->pcdata = new_pcdata(); fOld = FALSE; sprintf( buf, "%s%s", PLAYER_DIR, capitalize( arg ) ); if ( ( fp = fopen( buf, "r" ) ) != NULL ) { int iNest; for ( iNest = 0; iNest < MAX_NEST; iNest++ ) rgObjNest[iNest] = NULL; fOld = TRUE; for ( ; ; ) { char letter; char *word; letter = fread_letter( fp ); if ( letter == '*' ) { fread_to_eol( fp ); continue; } if ( letter != '#' ) { bug( "Load_char_obj: # not found.", 0 ); break; } word = fread_word( fp ); if ( !str_cmp( word, "PLAYER" ) ) fread_char( victim, fp ); else if ( !str_cmp( word, "OBJECT" ) ) break; else if ( !str_cmp( word, "O" ) ) break; else if ( !str_cmp( word, "PET" ) ) break; else if ( !str_cmp( word, "END" ) ) break; else { bug( "Load_char_obj: bad section.", 0 ); break; } } fclose( fp ); } if ( !fOld ) { send_to_char("No player by that name exists.\n\r",ch); free_pcdata(victim->pcdata); free_char(victim); return; } if ( (victim->level > LEVEL_HERO) && (victim->level > ch->level) ) { send_to_char("The gods wouldn't like that.\n\r",ch); free_pcdata(victim->pcdata); free_char(victim); return; } sprintf(buf,"%s last logged off on %s", victim->name, (char *) ctime(&victim->llogoff)); send_to_char(buf,ch); free_pcdata(victim->pcdata); free_char(victim); return; }
/* Extract a ch completely from the world, and leave his stuff behind */ void extract_char_smarter(struct char_data *ch, int save_room) { struct obj_data *i; struct char_data *k, *next_char; struct descriptor_data *t_desc; int l, was_in, j; extern long mob_count; extern struct char_data *combat_list; void do_save(struct char_data *ch, char *argument, int cmd); void do_return(struct char_data *ch, char *argument, int cmd); void die_follower(struct char_data *ch); if(IS_SET(ch->specials.act, ACT_FIGURINE) && ch->link) extract_obj(ch->link); if(!IS_NPC(ch) && !ch->desc) { for(t_desc = descriptor_list; t_desc; t_desc = t_desc->next) if(t_desc->original==ch) do_return(t_desc->character, "", 0); } if (ch->in_room == NOWHERE) { logE("NOWHERE extracting char. (handler.c, extract_char)"); /* ** problem from linkdeath */ char_to_room(ch, 4); /* 4 == all purpose store */ } if (ch->followers || ch->master) die_follower(ch); if(ch->desc) { /* Forget snooping */ if ((ch->desc->snoop.snooping) && (ch->desc->snoop.snooping->desc)) ch->desc->snoop.snooping->desc->snoop.snoop_by = 0; if (ch->desc->snoop.snoop_by) { send_to_char("Your victim is no longer among us.\n\r", ch->desc->snoop.snoop_by); if (ch->desc->snoop.snoop_by->desc) ch->desc->snoop.snoop_by->desc->snoop.snooping = 0; } ch->desc->snoop.snooping = ch->desc->snoop.snoop_by = 0; } if (ch->carrying) { /* transfer ch's objects to room */ if (!IS_IMMORTAL(ch)) { while(ch->carrying) { i=ch->carrying; obj_from_char(i); obj_to_room(i, ch->in_room); check_falling_obj(i, ch->in_room); } } else { send_to_char("Here, you dropped some stuff, let me help you get rid of that.\n\r",ch); /* equipment too */ for (j=0; j<MAX_WEAR; j++) { if (ch->equipment[j]) obj_to_char(unequip_char(ch, j), ch); } while (ch->carrying) { i = ch->carrying; obj_from_char(i); extract_obj(i); } } } if (ch->specials.fighting) stop_fighting(ch); for (k = combat_list; k ; k = next_char) { next_char = k->next_fighting; if (k->specials.fighting == ch) stop_fighting(k); } if (MOUNTED(ch)) { Dismount(ch, MOUNTED(ch), POSITION_STANDING); } if (RIDDEN(ch)) { Dismount(RIDDEN(ch), ch, POSITION_STANDING); } /* Must remove from room before removing the equipment! */ was_in = ch->in_room; char_from_room(ch); /* clear equipment_list */ for (l = 0; l < MAX_WEAR; l++) if (ch->equipment[l]) obj_to_room(unequip_char(ch,l), was_in); if (IS_NPC(ch)) { for (k=character_list; k; k=k->next) { if (k->specials.hunting) if (k->specials.hunting == ch) { k->specials.hunting = 0; } if (Hates(k, ch)) { RemHated(k, ch); } if (Fears(k, ch)) { RemFeared(k, ch); } if (k->orig == ch) { k->orig = 0; } } } else { for (k=character_list; k; k=k->next) { if (k->specials.hunting) if (k->specials.hunting == ch) { k->specials.hunting = 0; } if (Hates(k, ch)) { ZeroHatred(k, ch); } if (Fears(k, ch)) { ZeroFeared(k, ch); } if (k->orig == ch) { k->orig = 0; } } } /* pull the char from the list */ if (ch == character_list) character_list = ch->next; else { for(k = character_list; (k) && (k->next != ch); k = k->next); if(k) k->next = ch->next; else { logE("Trying to remove ?? from character_list.(handler.c,extract_char)"); exit(0); } } if (ch->specials.gname) free(ch->specials.gname); GET_AC(ch) = 100; if (ch->desc) { if (ch->desc->original) do_return(ch, "", 0); if (!strcmp(GET_NAME(ch), "Odin's heroic minion")) { free(GET_NAME(ch)); GET_NAME(ch) = strdup("111111"); } save_char(ch, save_room); } t_desc = ch->desc; if(ch->term) { ScreenOff(ch); ch->term = 0; } if (IS_NPC(ch)) { if (ch->nr > -1) /* if mobile */ mob_index[ch->nr].number--; FreeHates(ch); FreeFears(ch); mob_count--; free_char(ch); } if (t_desc) { t_desc->connected = CON_SLCT; SEND_TO_Q(MENU, t_desc); } }
/* Extract a ch completely from the world, and leave his stuff behind */ void extract_char(struct char_data * ch) { struct char_data *k, *temp; struct descriptor_data *t_desc; struct obj_data *obj; int i, freed = 0; //int j; extern struct char_data *combat_list; ACMD(do_return); void die_follower(struct char_data * ch); if (!IS_NPC(ch) && !ch->desc) { for (t_desc = descriptor_list; t_desc; t_desc = t_desc->next) { if (t_desc->original == ch) { do_return(t_desc->character, "", 0, 0); } } } if (ch->in_room == NOWHERE) { log("SYSERR: NOWHERE extracting char. (handler.c, extract_char)"); exit(1); } if (ch->followers || ch->master) { die_follower(ch); } if (RIDING(ch) || RIDDEN_BY(ch)) dismount_char(ch); REMOVE_BIT(PLR_FLAGS(ch), PLR_FISHING); REMOVE_BIT(PLR_FLAGS(ch), PLR_FISH_ON); REMOVE_BIT(PLR_FLAGS(ch), PLR_DIGGING); REMOVE_BIT(PLR_FLAGS(ch), PLR_DIG_ON); REMOVE_BIT(PLR_FLAGS(ch), PLR_FIRE_ON); REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF); //REMOVE_BIT(PRF_FLAGS(ch), PRF_DISGUISE); //REMOVE_BIT(PLR_FLAGS(ch), PLR_MAGE); //REMOVE_BIT(PLR_FLAGS(ch), PLR_MONK); //REMOVE_BIT(PLR_FLAGS(ch), PLR_KNIGHT); //REMOVE_BIT(PLR_FLAGS(ch), PLR_CLERIC); //REMOVE_BIT(PLR_FLAGS(ch), PLR_BARD); //REMOVE_BIT(PLR_FLAGS(ch), PLR_BEGGAR); REMOVE_BIT(PLR_FLAGS(ch), PLR_COURIER); REMOVE_BIT(PLR_FLAGS(ch), PLR_BEAR); REMOVE_BIT(PLR_FLAGS(ch), PLR_BIRD); REMOVE_BIT(PLR_FLAGS(ch), PLR_WOLF); REMOVE_BIT(PLR_FLAGS(ch), PLR_RABBIT); REMOVE_BIT(PLR_FLAGS(ch), PLR_CAT); /* Forget snooping, if applicable */ if (ch->desc) { if (ch->desc->snooping) { ch->desc->snooping->snoop_by = NULL; ch->desc->snooping = NULL; } if (ch->desc->snoop_by) { SEND_TO_Q("Your victim is no longer among us.\r\n", ch->desc->snoop_by); ch->desc->snoop_by->snooping = NULL; ch->desc->snoop_by = NULL; } } /* transfer objects to room, if any */ while (ch->carrying) { obj = ch->carrying; obj_from_char(obj); obj_to_room(obj, ch->in_room); } /* transfer equipment to room, if any */ for (i = 0; i < NUM_WEARS; i++) { if (GET_EQ(ch, i)) { obj_to_room(unequip_char(ch, i), ch->in_room); } } if (FIGHTING(ch)) { stop_fighting(ch); } for (k = combat_list; k; k = temp) { temp = k->next_fighting; if (FIGHTING(k) == ch) { stop_fighting(k); } } char_from_room(ch); /* pull the char from the list */ REMOVE_FROM_LIST(ch, character_list, next); if (ch->desc && ch->desc->original) { do_return(ch, NULL, 0, 0); } if (!IS_NPC(ch)) { save_char(ch, NOWHERE); Crash_delete_crashfile(ch); } else { if (GET_MOB_RNUM(ch) > -1) { /* if mobile */ mob_index[GET_MOB_RNUM(ch)].number--; } clearMemory(ch); /* Only NPC's can have memory */ if (SCRIPT(ch)) { extract_script(SCRIPT(ch)); } free_char(ch); freed = 1; } if (!freed && ch->desc != NULL) { STATE(ch->desc) = CON_MENU; SEND_TO_Q(MENU, ch->desc); } else { /* if a player gets purged from within the game */ if (ch->master || ch->followers) die_follower(ch); if (!freed) { free_char(ch); } } }
int main(int argc, char **args) { char *str = (char *) malloc(200); do { printf("Please enter the expression(Enter \"exit\" to quit): "); scanf("%s", str); if (strcmp(str, "exit") == 0) { break; } //构建栈 s_stack s; stack_init(&s, free_char); char *p = str; bool isValid = true; //遍历表达式 while (*p != '\0') { //如果是左括号,入栈 if (*p == '(' || *p == '[' || *p == '{') { char *ch = (char *) malloc(1); *ch = *p; stack_push(&s, ch); } //如果是右括号,出栈 else if (*p == ')' || *p == ']' || *p == '}') { char *ch; if (s.ele_count == 0) { isValid = false; break; } stack_pop(&s, &ch); //左右括号匹配合法 if ((*ch == '(' && *p == ')') || (*ch == '[' && *p == ']') || (*ch == '{' && *p == '}')) { free_char(ch); } //左右括号匹配非法 else { free_char(ch); isValid = false; break; } } p++; if (*p == '\0' && s.ele_count > 0) { isValid = false; break; } } //销毁栈 stack_destroy(&s); if (isValid) { printf("%s OK.\n", str); } else { printf("\"%s\" expression is invalid.\n", str); } } while (1); free(str); return 0; }
/* Extract a ch completely from the world, and leave his stuff behind */ void extract_char_final(struct char_data *ch) { struct char_data *k, *temp; struct descriptor_data *d; struct obj_data *obj; int i; if (IN_ROOM(ch) == NOWHERE) { log("SYSERR: NOWHERE extracting char %s. (%s, extract_char_final)", GET_NAME(ch), __FILE__); exit(1); } /* We're booting the character of someone who has switched so first we need * to stuff them back into their own body. This will set ch->desc we're * checking below this loop to the proper value. */ if (!IS_NPC(ch) && !ch->desc) { for (d = descriptor_list; d; d = d->next) if (d->original == ch) { do_return(d->character, NULL, 0, 0); break; } } if (ch->desc) { /* This time we're extracting the body someone has switched into (not the * body of someone switching as above) so we need to put the switcher back * to their own body. If this body is not possessed, the owner won't have a * body after the removal so dump them to the main menu. */ if (ch->desc->original) do_return(ch, NULL, 0, 0); else { /* Now we boot anybody trying to log in with the same character, to help * guard against duping. CON_DISCONNECT is used to close a descriptor * without extracting the d->character associated with it, for being * link-dead, so we want CON_CLOSE to clean everything up. If we're * here, we know it's a player so no IS_NPC check required. */ for (d = descriptor_list; d; d = d->next) { if (d == ch->desc) continue; if (d->character && GET_IDNUM(ch) == GET_IDNUM(d->character)) STATE(d) = CON_CLOSE; } STATE(ch->desc) = CON_MENU; write_to_output(ch->desc, "%s", CONFIG_MENU); } } /* On with the character's assets... */ if (ch->followers || ch->master) die_follower(ch); /* Check to see if we are grouped! */ if (GROUP(ch)) leave_group(ch); /* transfer objects to room, if any */ while (ch->carrying) { obj = ch->carrying; obj_from_char(obj); obj_to_room(obj, IN_ROOM(ch)); } /* transfer equipment to room, if any */ for (i = 0; i < NUM_WEARS; i++) if (GET_EQ(ch, i)) obj_to_room(unequip_char(ch, i), IN_ROOM(ch)); if (FIGHTING(ch)) stop_fighting(ch); for (k = combat_list; k; k = temp) { temp = k->next_fighting; if (FIGHTING(k) == ch) stop_fighting(k); } /* Whipe character from the memory of hunters and other intelligent NPCs... */ for (temp = character_list; temp; temp = temp->next) { /* PCs can't use MEMORY, and don't use HUNTING() */ if (!IS_NPC(temp)) continue; /* If "temp" is hunting our extracted char, stop the hunt. */ if (HUNTING(temp) == ch) HUNTING(temp) = NULL; /* If "temp" has allocated memory data and our ch is a PC, forget the * extracted character (if he/she is remembered) */ if (!IS_NPC(ch) && GET_POS(ch) == POS_DEAD && MEMORY(temp)) forget(temp, ch); /* forget() is safe to use without a check. */ } char_from_room(ch); if (IS_NPC(ch)) { if (GET_MOB_RNUM(ch) != NOTHING) /* prototyped */ mob_index[GET_MOB_RNUM(ch)].number--; clearMemory(ch); if (SCRIPT(ch)) extract_script(ch, MOB_TRIGGER); if (SCRIPT_MEM(ch)) extract_script_mem(SCRIPT_MEM(ch)); } else { save_char(ch); Crash_delete_crashfile(ch); } /* If there's a descriptor, they're in the menu now. */ if (IS_NPC(ch) || !ch->desc) free_char(ch); }
int make_fasta_gotoh_pair_wise (Alignment *A,int*ns, int **l_s,Constraint_list *CL, int *diag) { /*TREATMENT OF THE TERMINAL GAP PENALTIES*/ /*TG_MODE=0---> gop and gep*/ /*TG_MODE=1---> --- gep*/ /*TG_MODE=2---> --- ---*/ int TG_MODE, gop, l_gop, gep,l_gep, maximise; /*VARIABLES FOR THE MULTIPLE SEQUENCE ALIGNMENT*/ int a, b,c,k, t; int l1, l2,eg, ch, sub,score=0, last_i=0, last_j=0, i, delta_i, j, pos_j, ala, alb, LEN, n_diag, match1, match2; int su, in, de, tr; int **C, **D, **I, **trace, **pos0, **LD; int lenal[2], len; char *buffer, *char_buf; char **aln, **al; /********Prepare Penalties******/ gop=CL->gop*SCORE_K; gep=CL->gep*SCORE_K; TG_MODE=CL->TG_MODE; maximise=CL->maximise; /********************************/ n_diag=diag[0]; l1=lenal[0]=strlen (A->seq_al[l_s[0][0]]); l2=lenal[1]=strlen (A->seq_al[l_s[1][0]]); if ( getenv ("DEBUG_TCOFFEE"))fprintf ( stderr, "\n\tNdiag=%d%% ", (diag[0]*100)/(l1+l2)); /*diag: diag[1..n_diag]--> flaged diagonal in order; diag[0]=0--> first diagonal; diag[n_diag+1]=l1+l2-1; */ /*numeration of the diagonals strats from the bottom right [1...l1+l2-1]*/ /*sequence s1 is vertical and seq s2 is horizontal*/ /*D contains the best Deletion in S2==>comes from diagonal N+1*/ /*I contains the best insertion in S2=> comes from diagonal N-1*/ C=declare_int (lenal[0]+lenal[1]+1, n_diag+2); D=declare_int (lenal[0]+lenal[1]+1, n_diag+2); LD=declare_int (lenal[0]+lenal[1]+1, n_diag+2); I=declare_int (lenal[0]+lenal[1]+1, n_diag+2); trace=declare_int (lenal[0]+lenal[1]+1, n_diag+2); al=declare_char (2,lenal[0]+lenal[1]+lenal[1]+1); len= MAX(lenal[0],lenal[1])+1; buffer=(char*)vcalloc ( 2*len, sizeof (char)); char_buf=(char*) vcalloc (2*len, sizeof (char)); pos0=aln2pos_simple ( A,-1, ns, l_s); C[0][0]=0; t=(TG_MODE==0)?gop:0; for ( j=1; j<= n_diag; j++) { l_gop=(TG_MODE==0)?gop:0; l_gep=(TG_MODE==2)?0:gep; if ( (diag[j]-lenal[0])<0 ) { trace[0][j]=UNDEFINED; continue; } C[0][j]=(diag[j]-lenal[0])*l_gep +l_gop; D[0][j]=(diag[j]-lenal[0])*l_gep +l_gop+gop; } D[0][j]=D[0][j-1]+gep; t=(TG_MODE==0)?gop:0; for ( i=1; i<=lenal[0]; i++) { l_gop=(TG_MODE==0)?gop:0; l_gep=(TG_MODE==2)?0:gep; C[i][0]=C[i][n_diag+1]=t=t+l_gep; I[i][0]=D[i][n_diag+1]=t+ gop; for ( j=1; j<=n_diag; j++) { C[i][j]=C[i][0]; D[i][j]=I[i][j]=I[i][0]; } for (eg=0, j=1; j<=n_diag; j++) { pos_j=diag[j]-lenal[0]+i; if (pos_j<=0 || pos_j>l2 ) { trace[i][j]=UNDEFINED; continue; } sub=(CL->get_dp_cost) ( A, pos0, ns[0], l_s[0], i-1, pos0, ns[1], l_s[1],pos_j-1, CL ); /*1 identify the best insertion in S2:*/ l_gop=(i==lenal[0])?((TG_MODE==0)?gop:0):gop; l_gep=(i==lenal[0])?((TG_MODE==2)?0:gep):gep; len=(j==1)?0:(diag[j]-diag[j-1]); if ( a_better_than_b(I[i][j-1], C[i][j-1]+l_gop, maximise))eg++; else eg=1; I[i][j]=best_of_a_b (I[i][j-1], C[i][j-1]+l_gop, maximise)+len*l_gep; /*2 Identify the best deletion in S2*/ l_gop=(pos_j==lenal[1])?((TG_MODE==0)?gop:0):gop; l_gep=(pos_j==lenal[1])?((TG_MODE==2)?0:gep):gep; len=(j==n_diag)?0:(diag[j+1]-diag[j]); delta_i=((i-len)>0)?(i-len):0; if ( a_better_than_b(D[delta_i][j+1],C[delta_i][j+1]+l_gop, maximise)){LD[i][j]=LD[delta_i][j+1]+1;} else {LD[i][j]=1;} D[i][j]=best_of_a_b (D[delta_i][j+1],C[delta_i][j+1]+l_gop, maximise)+len*l_gep; /*Identify the best way*/ /* score=C[i][j]=best_int ( 3, maximise, &fop, I[i][j], C[i-1][j]+sub, D[i][j]); fop-=1; if ( fop<0)trace[i][j]=fop*eg; else if ( fop>0 ) {trace[i][j]=fop*LD[i][j];} else if ( fop==0) trace[i][j]=0; */ su=C[i-1][j]+sub; in=I[i][j]; de=D[i][j]; /*HERE ("%d %d %d", su, in, de);*/ if (su>=in && su>=de) { score=su; tr=0; } else if (in>=de) { score=in; tr=-eg; } else { score=de; tr=LD[i][j]; } trace[i][j]=tr; C[i][j]=score; last_i=i; last_j=j; } } /* [0][Positive] ^ ^ | / | / | / | / |/ [Neg]<-------[*] */ i=last_i; j=last_j; ala=alb=0; match1=match2=0; while (!(match1==l1 && match2==l2)) { if ( match1==l1) { len=l2-match2; for ( a=0; a< len; a++) { al[0][ala++]=0; al[1][alb++]=1; match2++; } k=0; break; /*k=-(j-1);*/ } else if ( match2==l2) { len=l1-match1; for ( a=0; a< len; a++) { al[0][ala++]=1; al[1][alb++]=0; match1++; } k=0; break; /*k= n_diag-j;*/ } else { k=trace[i][j]; } if ( k==0) { if ( match2==l2 || match1==l1); else { al[0][ala++]=1; al[1][alb++]=1; i--; match1++; match2++; } } else if ( k>0) { len=diag[j+k]-diag[j]; for ( a=0; a<len; a++) { if ( match1==l1)break; al[0][ala++]=1; al[1][alb++]=0; match1++; } i-=len; j+=k; } else if ( k<0) { k*=-1; len=diag[j]-diag[j-k]; for ( a=0; a<len; a++) { if ( match2==l2)break; al[0][ala++]=0; al[1][alb++]=1; match2++; } j-=k; } } LEN=ala; c=LEN-1; invert_list_char ( al[0], LEN); invert_list_char ( al[1], LEN); if ( A->declared_len<=LEN)A=realloc_aln2 ( A,A->max_n_seq, 2*LEN); aln=A->seq_al; for ( c=0; c< 2; c++) { for ( a=0; a< ns[c]; a++) { ch=0; for ( b=0; b< LEN; b++) { if (al[c][b]==1) char_buf[b]=aln[l_s[c][a]][ch++]; else char_buf[b]='-'; } char_buf[b]='\0'; aln[l_s[c][a]]=csprintf (aln[l_s[c][a]],"%s", char_buf); } } A->len_aln=LEN; A->nseq=ns[0]+ns[1]; free_int (pos0, -1); free_int (C, -1); free_int (D, -1); free_int (I, -1); free_int (trace, -1); free_int (LD, -1); free_char ( al, -1); vfree(buffer); vfree(char_buf); return score; }
int myers_miller_pair_wise (Alignment *A,int *ns, int **ls,Constraint_list *CL ) { int **pos; int a,b, i, j, l,l1, l2, len; int *S; char ** char_buf; int score; /********Prepare Penalties******/ //ns2master_ns (ns,ls, &sns,&sls); sns=ns; sls=ls; /********************************/ pos=aln2pos_simple ( A,-1, ns, ls); l1=strlen (A->seq_al[ls[0][0]]); l2=strlen (A->seq_al[ls[1][0]]); S=(int*)vcalloc (l1+l2+1, sizeof (int)); last=0; sapp=S; score=diff (A,ns, ls, 0, l1, 0, l2, 0, 0, CL, pos); diff (NULL,ns, ls, 0, l1, 0, l2, 0, 0, CL, pos); i=0; j=0; sapp=S; len=0; while (!(i==l1 && j==l2)) { if (*sapp==0) { i++; j++; len++; } else if ( *sapp<0) { i-=*sapp; len-=*sapp; } else if ( *sapp>0) { j+=*sapp; len+=*sapp; } sapp++; } A=realloc_aln2 ( A,A->max_n_seq,len+1); char_buf=declare_char (A->max_n_seq,len+1); i=0; j=0; sapp=S; len=0; while (!(i==l1 && j==l2)) { if (*sapp==0) { for (b=0; b< ns[0]; b++) char_buf[ls[0][b]][len]=A->seq_al[ls[0][b]][i]; for (b=0; b< ns[1]; b++) char_buf[ls[1][b]][len]=A->seq_al[ls[1][b]][j]; i++; j++; len++; } else if ( *sapp>0) { l=*sapp; for ( a=0; a<l; a++, j++, len++) { for (b=0; b< ns[0]; b++) char_buf[ls[0][b]][len]='-'; for (b=0; b< ns[1]; b++) char_buf[ls[1][b]][len]=A->seq_al[ls[1][b]][j]; } } else if ( *sapp<0) { l=-*sapp; for ( a=0; a<l; a++, i++, len++) { for (b=0; b< ns[0]; b++) char_buf[ls[0][b]][len]=A->seq_al[ls[0][b]][i];; for (b=0; b< ns[1]; b++) char_buf[ls[1][b]][len]='-'; } } sapp++; } A->len_aln=len; A->nseq=ns[0]+ns[1]; for ( a=0; a< ns[0]; a++) { char_buf[ls[0][a]][len]='\0'; sprintf ( A->seq_al[ls[0][a]], "%s", char_buf[ls[0][a]]); } for ( a=0; a< ns[1]; a++) { char_buf[ls[1][a]][len]='\0'; sprintf ( A->seq_al[ls[1][a]], "%s", char_buf[ls[1][a]]); } vfree (S); free_char ( char_buf, -1); l1=strlen (A->seq_al[ls[0][0]]); l2=strlen (A->seq_al[ls[1][0]]); if ( l1!=l2) exit(1); free_int (pos, -1); return score; }
//leci po liscie artow i sprawdza wszystkie pliki graczy z llisty void scan_players_for_artefacts() { struct dirent * pDirent = NULL; DIR *pDir = NULL; ARTEFACT_DATA *atmp = NULL; ARTEFACT_OWNER *otmp = NULL; ARTEFACT_STORER *storer = NULL, *temp_storer = NULL, *first_storer = NULL; int czas; pDir = opendir( "../player/" ); if ( !pDir ) { bugf( "Cannot open players directory. Skipping check." ); return; // can't continue. } //jedziemy po plikach while ( TRUE ) { pDirent = readdir( pDir ); if ( !pDirent ) { break; } for ( atmp = artefact_system; atmp; atmp = atmp->next ) { for ( otmp = atmp->first_owner;otmp;otmp = otmp->next ) { { CHAR_DATA * ch; ch = load_char_remote( otmp->owner ); if ( !ch ) { remove_name_from_artefact_list( otmp->owner ); continue; } otmp->last_logoff = ch->pcdata->last_logoff; free_char( ch ); } remove_artefact_art_destroy( otmp->owner ); //i tu tera sprawdzanie przetrzymywania czas = ( current_time - ( otmp->last_logoff ) ) / ( 24 * 60 * 60 ); if ( atmp->max_day < czas ) //przetrzymane, zabieramy kolesiowi { storer = new_storer_data(); storer->name = otmp->owner; storer->vnum = atmp->avnum; storer->next = NULL; if ( first_storer == NULL ) { first_storer = storer; } else { temp_storer->next = storer; } temp_storer = storer; } } /*alast=atmp;*/ } //fory break; } closedir( pDir ); //dobra to teraz wywalanie,modlmy sie zeby dzialalo for ( temp_storer = first_storer;temp_storer;temp_storer = temp_storer->next ) { remove_artefact_remote( temp_storer->name, temp_storer->vnum ); } return ; }
int make_fasta_cdna_pair_wise (Alignment *B,Alignment *A,int*in_ns, int **l_s,Constraint_list *CL, int *diag) { int a,c,p,k; Dp_Result *DPR; static Dp_Model *M; int l0, l1; int len_i, len_j; int f0=0, f1=0; int deltaf0, deltaf1, delta; int nr1, nr2; int ala, alb, aa0, aa1; int type; char **al; int **tl_s; int *tns; /*DEBUG*/ int debug_cdna_fasta=0; Alignment *DA; int score; int state,prev_state; int t, e; int a1, a2; l0=strlen ( B->seq_al[l_s[0][0]]); l1=strlen ( B->seq_al[l_s[1][0]]); al=declare_char (2, l0+l1+1); B=realloc_aln2 (B,B->nseq,l0+l1+1); free_int (B->cdna_cache, -1); B->cdna_cache=declare_int(1, l0+l1+1); if ( !M)M=initialize_dna_dp_model (CL); M->diag=diag; tl_s=declare_int (2, 2);tns=vcalloc(2, sizeof(int));tl_s[0][0]=0;tl_s[1][0]=3;tns[0]=tns[1]=1; DPR=make_fast_dp_pair_wise (A,tns, tl_s,CL,M); vfree(tns);free_int(tl_s, -1); /*new_trace_back*/ a=p=0; aa0=aa1=ala=alb=0; while ( (k=DPR->traceback[a++])!=M->START); while ( (k=DPR->traceback[a++])!=M->END) { f0=M->model_properties[k][M->F0]; f1=M->model_properties[k][M->F1]; len_i=M->model_properties[k][M->LEN_I]; len_j=M->model_properties[k][M->LEN_J]; type=M->model_properties[k][M->TYPE]; if (type==M->CODING0) { deltaf0=(aa0*3+f0)-ala; deltaf1=(aa1*3+f1)-alb; delta=MAX(deltaf0, deltaf1); for (nr1=0, nr2=0,c=0; c<delta; c++, nr1++, nr2++,p++) { if (nr1<deltaf0 && ala<l0)al[0][p]=B->seq_al[l_s[0][0]][ala++]; else al[0][p]='-'; if (nr2<deltaf1 && alb<l1)al[1][p]=B->seq_al[l_s[1][0]][alb++]; else al[1][p]='-'; B->cdna_cache[0][p]=M->NON_CODING; if ( is_gap(al[1][p]) && is_gap(al[0][p]))p--; else if ( debug_cdna_fasta)fprintf (stderr, "\nUM: %c %c", al[0][p], al[1][p]); } for ( c=0; c< 3; c++, p++) { if ( c==0)B->cdna_cache[0][p]=M->CODING0; else if ( c==1)B->cdna_cache[0][p]=M->CODING1; else if ( c==2)B->cdna_cache[0][p]=M->CODING2; if (ala<l0)al[0][p]=B->seq_al[l_s[0][0]][ala++]; else al[0][p]='-'; if (alb<l1)al[1][p]=B->seq_al[l_s[1][0]][alb++]; else al[1][p]='-'; if ( is_gap(al[1][p]) && is_gap(al[0][p]))p--; else if ( debug_cdna_fasta)fprintf (stderr, "\n%d: %c %c",k, al[0][p], al[1][p]); } } aa0+=len_i; aa1+=len_j; } deltaf0=(aa0*3+f0)-ala; deltaf1=(aa1*3+f1)-alb; delta=MAX(deltaf0, deltaf1); for (nr1=0, nr2=0,c=0; c<delta; c++, nr1++, nr2++,p++) { if (nr1<deltaf0 && ala<l0)al[0][p]=B->seq_al[l_s[0][0]][ala++]; else al[0][p]='-'; if (nr2<deltaf1 && alb<l1)al[1][p]=B->seq_al[l_s[1][0]][alb++]; else al[1][p]='-'; B->cdna_cache[0][p]=M->NON_CODING; if ( is_gap(al[1][p]) && is_gap(al[0][p]))p--; else if ( debug_cdna_fasta)fprintf (stderr, "\nUM: %c %c", al[0][p], al[1][p]); } /*End New traceback*/ al[0][p]='\0'; al[1][p]='\0'; sprintf( B->seq_al[l_s[0][0]], "%s", al[0]); sprintf( B->seq_al[l_s[1][0]], "%s", al[1]); B->len_aln=strlen (al[0]); B->nseq=2; if ( debug_cdna_fasta) { fprintf ( stderr, "\nA-A=%d, %d", CL->M['a'-'A']['a'-'A'], CL->M['a'-'A']['a'-'A'] *SCORE_K); for ( a=1; a<diag[0]; a++) { fprintf ( stderr, "\nchosen diag: %d", diag[a]); } fprintf ( stderr, "\n GOP=%d GEP=%d TG_MODE=%d", M->gop, M->gep, M->TG_MODE); fprintf ( stderr, "\nF_GOP=%d F_GEP=%d F_TG_MODE=%d", M->gop, M->gep, M->F_TG_MODE); DA=copy_aln (B, NULL); DA=realloc_aln2 (DA,6,(DA->len_aln+1)); for ( a=0; a<B->len_aln; a++) { fprintf ( stderr, "\n%d", DA->cdna_cache[0][a]); if (DA->cdna_cache[0][a]>=M->CODING0)DA->seq_al[DA->nseq][a]=DA->cdna_cache[0][a]-M->nstate+'0'; else DA->seq_al[DA->nseq][a]=DA->cdna_cache[0][a]-M->nstate+'0'; if (DA->cdna_cache[0][a]==M->CODING0) { DA->seq_al[DA->nseq+1][a]=translate_dna_codon (DA->seq_al[0]+a,'*'); DA->seq_al[DA->nseq+2][a]=translate_dna_codon (DA->seq_al[1]+a,'*'); } else { DA->seq_al[DA->nseq+1][a]='-'; DA->seq_al[DA->nseq+2][a]='-'; } } DA->nseq+=3; print_aln (DA); free_aln(DA); score=0; for (prev_state=M->START,a=0; a< DA->len_aln;) { state=DA->cdna_cache[0][a]; t=M->model[prev_state][state]; if ( DA->cdna_cache[0][a]==M->CODING0) { a1=translate_dna_codon (A->seq_al[0]+a,'x'); a2=translate_dna_codon (A->seq_al[1]+a,'x'); if ( a1!='x' && a2!='x') { e=CL->M[a1-'A'][a2-'A']*SCORE_K; } } else if ( DA->cdna_cache[0][a]>M->CODING0); else { e=M->model_properties[B->cdna_cache[0][a]][M->EMISSION]; } if ( e==UNDEFINED || t==UNDEFINED) fprintf ( stderr, "\nPROBLEM %d\n", a); fprintf ( stderr, "\n[%c..%c: %d(e)+%d(t)=%d]", A->seq_al[0][a], A->seq_al[1][a], e,t,e+t); score+=e+t; prev_state=state; if (B->cdna_cache[0][a]==M->NON_CODING)a++; else a+=3; } } for ( a=0; a<B->len_aln; a++) { if ( B->cdna_cache[0][a]<M->CODING0)B->cdna_cache[0][a]=0; else B->cdna_cache[0][a]=1; } free_char ( al, -1); return DPR->score; }
Sequence *free_constraint_list (Constraint_list *CL) { Sequence *S; int a, b; Constraint_list *pCL; /*Prepare the selective freeing of the CL data structure: If the CL has been obtained from copy, every pointer that is identical to the parent CL (CL->pCL) will not be saved. */ if ( !CL)return NULL; else S=CL->S; if ( CL->copy_mode==SOFT_COPY && !CL->pCL) {vfree(CL); return S;} else if ( CL->copy_mode==SOFT_COPY) { pCL=CL->pCL; CL->residue_index=NULL; if ( CL->M ==pCL->M )CL->M=NULL; if (CL->start_index ==pCL->start_index )CL->start_index=NULL; if (CL->end_index ==pCL->end_index )CL->end_index=NULL; if ( CL->fp ==pCL->fp )CL->fp=NULL; if ( CL->matrices_list ==pCL->matrices_list )CL->matrices_list=NULL; if ( CL->STRUC_LIST ==pCL->STRUC_LIST )CL->STRUC_LIST=NULL; if ( CL->W ==pCL->W )CL->W=NULL; if ( CL->DM ==pCL->DM )CL->DM=NULL; if ( CL->ktupDM ==pCL->ktupDM )CL->ktupDM=NULL; if ( CL->translation ==pCL->translation )CL->translation=NULL; if ( CL->moca ==pCL->moca )CL->moca=NULL; if ( CL->Prot_Blast ==pCL->Prot_Blast )CL->Prot_Blast=NULL; if ( CL->DNA_Blast ==pCL->DNA_Blast )CL->DNA_Blast=NULL; if ( CL->Pdb_Blast ==pCL->Pdb_Blast )CL->Pdb_Blast=NULL; if ( CL->seq_for_quadruplet ==pCL->seq_for_quadruplet )CL->seq_for_quadruplet=NULL; if ( CL->TC ==pCL->TC )CL->TC=NULL; } /*End of selective freeing of the CL data structure*/ if ( CL->residue_index)free_arrayN(CL->residue_index, 3); if ( CL->M)free_int (CL->M, -1); if ( CL->fp)vfclose (CL->fp); if ( CL->matrices_list)free_char(CL->matrices_list,-1); if ( CL->start_index)free_int ( CL->start_index,-1); if ( CL->end_index)free_int ( CL->end_index,-1); if ( CL->STRUC_LIST)free_sequence ( CL->STRUC_LIST, (CL->STRUC_LIST)->nseq); if ( CL->W)free_weights (CL->W); CL->DM=free_distance_matrix (CL->DM); CL->ktupDM=free_distance_matrix (CL->ktupDM); if ( CL->translation)vfree(CL->translation); if ( CL->moca)free_moca (CL->moca); if ( CL->Prot_Blast)free_blast_param ( CL->Prot_Blast); if ( CL->DNA_Blast) free_blast_param ( CL->DNA_Blast); if ( CL->Pdb_Blast) free_blast_param ( CL->Pdb_Blast); if ( CL->TC) free_TC_param ( CL->TC); if (CL->seq_for_quadruplet)vfree (CL->seq_for_quadruplet); vfree(CL); return S; }
Alignment* copy_aln ( Alignment *A, Alignment *B) { int a, b; int nnseq; int nlen; /* c[100]=10;*/ if ( A==NULL){free_aln(B); return NULL;} nnseq=MAX(A->nseq, A->max_n_seq); nlen=A->len_aln+1; if (B) B=realloc_alignment2 (B, nnseq, nlen); else B=declare_aln2 (nnseq, nlen); B->S=A->S; /*SIZES*/ B->max_len=A->max_len; B->min_len=A->min_len; B->declared_len=nlen; B->max_n_seq=nnseq; B->nseq=A->nseq; B->len_aln=A->len_aln; /*sequence Information*/ if ( A->generic_comment) { vfree(B->generic_comment); B->generic_comment=vcalloc (strlen(A->generic_comment)+1, sizeof (char)); sprintf ( B->generic_comment, "%s", A->generic_comment); } if ( (A->S)==NULL){vfree (B->len); B->len=vcalloc ( A->max_n_seq, sizeof (int));} ga_memcpy_int ( A->len, B->len, B->nseq); B->seq_comment=copy_char ( A->seq_comment, B->seq_comment, -1,-1); B->aln_comment=copy_char ( A->aln_comment, B->aln_comment, -1,-1); B->name=copy_char ( A->name, B->name, -1,-1); B->file=copy_char ( A->file, B->file, -1,-1); B->tree_order=copy_char ( A->tree_order, B->tree_order, -1,-1); B->expanded_order=A->expanded_order; free_char ( B->seq_al, -1); B->seq_al=declare_char(B->max_n_seq, B->declared_len); // HERE ("A: MAX_NSEQ=%d %d %d %d",B->nseq, B->max_n_seq, B->declared_len, B->len_aln); // HERE ("B: MAX_NSEQ=%d %d %d %d",A->nseq, A->max_n_seq, A->declared_len, A->len_aln); for ( a=0; a< nnseq; a++) { if (A->seq_al[a]) { for ( b=0; b< A->len_aln; b++) B->seq_al[a][b]=A->seq_al[a][b]; } } B->order=copy_int ( A->order, B->order, -1, -1); B->S=A->S; if (A->seq_cache) { B->seq_cache=copy_int ( A->seq_cache, B->seq_cache,-1,-1); } if (A->cdna_cache) { B->cdna_cache=copy_int ( A->cdna_cache, B->cdna_cache,-1,-1); } B->P=copy_profile (A->P); B->Dp_result=A->Dp_result; /*Score*/ if ( (A->S)==NULL){vfree (B->score_seq); B->score_seq=vcalloc ( A->max_n_seq, sizeof (int));} ga_memcpy_int( A->score_seq,B->score_seq,B->nseq); B->score_res=A->score_res; B->score_aln=A->score_aln; B->score=A->score; B->ibit=A->ibit; B->cpu=A->cpu; B->finished=A->finished; /*Output Options*/ B->output_res_num=A->output_res_num; B->residue_case=A->residue_case; B->expand=A->expand; B->CL=A->CL; B->random_tag=A->random_tag; /*Make the function Recursive */ if ( A->A) { B->A=copy_aln (A->A, NULL); } else B->A=NULL; return B; }
void remove_artefact_remote( char *name, unsigned int vnum ) { CHAR_DATA * ch; OBJ_DATA *obj; char buf[ MAX_STRING_LENGTH ]; char buf1[ MAX_STRING_LENGTH ]; sprintf( buf1, "imie: %s vnum: %d", name, vnum ); log_string( buf1 ); //sprawdzalismy juz czy istnieje plik wiec: ch = load_char_remote( name ); if ( ch == NULL ) { bugf( "load_char_remote: no match '%s'.", name ); remove_name_from_artefact_list( ch->name ); return; } if ( !ch->carrying ) { free_char( ch ); return; } //dobra to szuka i od razu wywala z listy if ( ch->carrying->pIndexData->vnum == vnum ) { obj = ch->carrying; ch->carrying = ch->carrying->next_content; } else if ( ( obj = przeszukanie( ch->carrying, vnum, NULL ) ) == NULL ) { remove_name_from_artefact_list( ch->name ); restore_char_on_artefact_list( ch ); return ; } sprintf( buf, "ZABRANO PRZETRZYMYWANY ARTEFAKT: Posiadacz:%s Avnum:%s,%d", ch->name, obj->name, obj->pIndexData->vnum ); log_string( buf ); append_file_format_daily(NULL, ARTEFACT_LOG_FILE, "%s -> PRZETRZYMANY :%s vnum:%d (DEL)",ch->name, obj->short_descr, obj->pIndexData->vnum); get_money_from_rent( ch, obj ); //sprawdzic czy kase zapisuje na nowo //daty nie zmieniac przypadkiem !!! //logowac to //tu koncowe rzeczy obj->carried_by = NULL; obj->next_content = NULL; //to sprawdzic czy w workach tez liczone ch->carry_number -= get_obj_number( obj ); ch->carry_weight -= get_obj_weight( obj ); save_char_obj( ch, FALSE, TRUE ); //z TRUE nei zapisuje nowej daty //to cos zle dziala, dodaje zamiast odejmowac ;) remove_name_from_artefact_list( ch->name ); restore_char_on_artefact_list( ch ); free_char( ch ); return ; }