예제 #1
0
void done_skeldal(void)
  {

  SEND_LOG("(GAME) Video returned to textmode",0,0);
  close_manager();
  close_story_file();
  purge_temps(1);
  stop_mixing();
//  deinstall_mouse_handler();
  if (texty!=NULL) release_list(texty);texty=NULL;
  if (cur_config!=NULL) release_list(cur_config);cur_config=NULL;
  kill_timer();
  SEND_LOG("NORMAL TERMINATING--------------------------",0,0);
  }
예제 #2
0
TSTR_LIST read_config(const char *filename)
  {
  FILE *f;
  TSTR_LIST ls;
  char buff[256];

  f=fopen(filename,"r");
  if (f==NULL) return NULL;
  ls=create_list(256);
  while (!feof(f))
     {
     char *c;
     buff[0]=0;
     if (fgets(buff,256,f)==NULL) break;
     c=strchr(buff,'\n');if (c!=NULL) *c=0;
     if (ferror(f))
        {
        release_list(ls);
        fclose(f);
        return NULL;
        }
     str_add(&ls,buff);
     }
  fclose(f);
  return ls;
  }
예제 #3
0
파일: test_source.c 프로젝트: aajarven/c
END_TEST


START_TEST(test_delete_list)
{
    const int len = 4;
    struct product *l;

    struct product_list list;
    init_list(&list);

    fail_unless(add_product_exists(), "Delete_list: Implement add_product first!\n");

    char *titles[] = {"Floppy disk", "USB stick", "Something with quite long name", "Laptop"};    
    const char *codes[] = {"0000", "1234567", "4444444", "1111"};
    int stocks[] = {1, 2, 3, 4};
    double prices[] = {0.1, 1, 10, 100};

    l = add_product(&list, titles[0], codes[0], stocks[0], prices[0]);
    for (int i = 1; i < len; i++) {
        add_product(&list, titles[i], codes[i], stocks[i], prices[i]);
    }

    int ret = delete_list(&list);
    if (!ret) {
        release_list(list.head);
        fail("delete_list should return 1 after properly implemented\n");
    }
}
예제 #4
0
void edit_sector(int source)
  {
  TSECTOR *p;
  TSTR_LIST l;
  CTL3D b1,b2,b3;

  l=read_directory("c:\\windows\\system\\*.*",DIR_FULL,_A_NORMAL);
  p=&mapa.sectordef[source];
  memcpy(&b1,def_border(1,0),sizeof(CTL3D));
  memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D));
  memcpy(&b3,def_border(3,WINCOLOR),sizeof(CTL3D));
  default_font=vga_font;
  memcpy(f_default,flat_color(0x0000),sizeof(charcolors));
  def_dialoge(100,100,300,200,"String list - test only");
  define(9,10,20,240,170,0,listbox,l,0x1f);c_default(0);
  o_end->autoresizex=1;
  o_end->autoresizey=1;
  define(10,3,42,17,110,1,scroll_bar_v,0,10,1,SCROLLBARCOL);
  property(NULL,NULL,NULL,WINCOLOR);
  o_end->autoresizey=1;
  define(11,1,20,21,17,1,scroll_button,-1,0,"\x1e");
  property(NULL,icones,NULL,WINCOLOR);on_change(scroll_support);
  define(12,1,22,21,17,2,scroll_button,1,10,"\x1f");
  property(NULL,icones,NULL,WINCOLOR);on_change(scroll_support);
  define(20,1,1,10,10,2,resizer);
/*  define(OK_BUTT,100,5,80,20,2,button,"Ok");property(&b1,NULL,NULL,WINCOLOR);
    on_change(terminate);
  define(CANCEL_BUTT,10,5,80,20,2,button,"Zru¨it");property(&b1,NULL,NULL,WINCOLOR);
    on_change(terminate);
  define(-1,5,20,100,12,0,label,"P©ipojen¡:");
  define(10,10,35,50,12,0,input_line,20,0,MAPSIZE-1,"%6d");property(&b2,NULL,NULL,WINCOLOR);
    set_default(strs(p->step_next[0]));on_exit(test_int);
  define(20,10,50,50,12,0,input_line,20,0,MAPSIZE-1,"%6d");property(&b2,NULL,NULL,WINCOLOR);
    set_default(strs(p->step_next[1]));on_exit(test_int);
  define(30,10,65,50,12,0,input_line,20,0,MAPSIZE-1,"%6d");property(&b2,NULL,NULL,WINCOLOR);
    set_default(strs(p->step_next[2]));on_exit(test_int);
  define(40,10,80,50,12,0,input_line,20,0,MAPSIZE-1,"%6d");property(&b2,NULL,NULL,WINCOLOR);
    set_default(strs(p->step_next[3]));on_exit(test_int);
  define(50,70,35,80,12,0,button,"Sever");property(&b1,NULL,NULL,WINCOLOR);on_change(edit_side_sup);
  define(60,70,50,80,12,0,button,"V˜chod");property(&b1,NULL,NULL,WINCOLOR);on_change(edit_side_sup);
  define(70,70,65,80,12,0,button,"Jih");property(&b1,NULL,NULL,WINCOLOR);on_change(edit_side_sup);
  define(80,70,80,80,12,0,button,"Z pad");property(&b1,NULL,NULL,WINCOLOR);on_change(edit_side_sup);
  temp_source=source;
  */redraw_window();
  escape();
  close_window(waktual);
  release_list(l);
  }
예제 #5
0
void load_book()
  {
  char *c;
  FILE *f;
  char tx[512];

  if (all_text != NULL) release_list(all_text);
  all_text = NULL;
  concat(c,pathtable[SR_TEMP],BOOK_FILE);
  f = fopen(c,"r");if (f == NULL) return;
  all_text = create_list(256);
  while (fgets(tx,510,f) != NULL)
     {
     char *c;
     c = strchr(tx,0);c--;*c = 0;
     str_add(&all_text,tx);
     }
  fclose(f);
  }
예제 #6
0
/*-------------------------test our API---------------------------------*/
int main()
{
    struct node *p_head = init_list();
    int array[ARRAY_SIZE] = {1,2,3,4,5,6,7,8,9,10};

    int i = 0;
    for(i = 0; i < ARRAY_SIZE; i++)
    {
        if(list_insert(p_head, array[i]) < 0)
        {
            goto failed;
        }
    }

    list_show(p_head);
failed:
    release_list(p_head);
    return 0;
}
예제 #7
0
int main()
{
	hOut = GetStdHandle(STD_OUTPUT_HANDLE);  //标准输出句柄获得
	SetConsoleCursorInfo(hOut, &cur_info);  //隐藏光标
	while(1)
	{
		system("cls");/*清屏*/
		Snake* head = (Snake*)malloc(sizeof(Snake));
		initialization(head);
		background();
		while(1)
		{
			Sleep(500);
			refresh();
			getkeys();
			run(head);
			eat(head);
			if(door(head)) break;
			food(head);
		}
		release_list(head);
		SetConsoleCursorPosition(hOut, pos);
		SetConsoleTextAttribute(hOut, 0x07);
		system("cls");/*清屏*/
		printf("得分:%d\n空格重新开始\n",scoring);
		while(1)
		{
			int w = getch();
			if(w == ' ')
			{
				break;
			}
			else
			{
				continue;
			}
		}
	}
	return 0;
}
예제 #8
0
int save_map(char *filename)
  {
  long bytesize;
  FILE *f;
  char nerr=1;char *pr;
  int i,j;
  TSTR_LIST names=NULL;
  void *temp;
  char enpass[58];

  f=fopen(filename,"wb");
  if (f==NULL) return -1;

  for (i=1;i<maplen;i++)
     for (j=0;j<4;j++)
     {
     TSTENA *w;

     w=&mapa.sidedef[i][j];
     if (w->flags & 0x40000)
        if ((minfo[i].x+minfo[i].y+j)& 1)
          w->prim+=(w->prim_anim & 0xf)+1;
     }

  bytesize=sizeof(mglob);
  encrypt2(password,mglob.mappassw,sizeof(mglob.mappassw));
  if (nerr)
     nerr&=(bytesize==save_section(f,&mglob,A_MAPGLOB,bytesize));

  bytesize=maplen*sizeof(TSTENA)*4;
  if (nerr)
     nerr&=(bytesize==save_section(f,&mapa.sidedef,A_SIDEMAP,bytesize));

  bytesize=maplen*sizeof(TSECTOR);
  if (nerr)
     nerr&=(bytesize==save_section(f,&mapa.sectordef,A_SECTMAP,bytesize));

  if (password[0]) Shift_map_sectors_up();
  bytesize=maplen*sizeof(TMAP_EDIT_INFO);
  if (nerr)
     nerr&=(bytesize==save_section(f,&minfo,A_MAPINFO,bytesize));
  if (password[0]) Shift_map_sectors_down();
  pr=pripona(filename,SCR);
  for (i=1;i<8;i++)
     {

     switch (i)
        {
        case 1:
        case 2:
        case 3:read_side_script_one(pr,NSID,&names,i,4);break;
        case 4:read_side_script_one(pr,NCEI,&names,1,2);break;
        case 5:read_side_script_one(pr,NFLR,&names,1,2);break;
        case 6:read_side_script_one(pr,NOBL,&names,1,3);break;
        case 7:read_side_script_one(pr,NOBL,&names,2,3);break;
        }
     if (nerr)
     nerr&=save_scr_list(f,names,i==7?A_STRTAB7:A_STRTAB1+i-1);
     }

  strcpy(enpass,"Heslo \x8 je heslo");
  bytesize=strlen(enpass)+1;
    if (nerr && bytesize>1)
      {
      encrypt(enpass);
      memcpy(enpass+bytesize,"<BLOCK>\0\x13\x80",12);bytesize+=24;
      nerr&=(bytesize==save_section(f,enpass,A_PASSW,bytesize));
      }
  temp=save_macros(&bytesize);
   if (temp!=NULL)
     {
    if (nerr)
     nerr&=(bytesize==save_section(f,temp,A_MAPMACR,bytesize));
     free(temp);
     }

  if (nerr)
     nerr&=save_item_map(f,A_MAPITEM);

  if (mglob.local_monsters)
     {
     temp=save_mobs_to_map(&bytesize);
        if (nerr && temp!=NULL)
           nerr&=(bytesize==save_section(f,temp,A_MOBS,bytesize));
     free(temp);
     nerr&=save_sound_dat(f,A_MOBSND);
     }

  temp=save_mob_map(&bytesize);
   if (temp!=NULL)
     {
    if (nerr)
     nerr&=(bytesize==save_section(f,temp,A_MAPMOBS,bytesize));
     free(temp);
     }
  for(i=255;i>1;i--) if (vyklenky[i].sector!=0)  break;
  bytesize=sizeof(TVYKLENEK)*(i+1);
    if (nerr)
     nerr&=(bytesize==save_section(f,vyklenky,A_MAPVYK,bytesize));
  strcpy(enpass,"To bys \x8 chtel vedet co? \x8 ");
  bytesize=strlen(enpass)+1;
    if (nerr && bytesize>1)
      {
      encrypt(enpass);
      memcpy(enpass+bytesize,"<BLOCK>\0\x13\x80",12);bytesize+=12;
      nerr&=(bytesize==save_section(f,enpass,A_PASSW,bytesize));
      }
  bytesize=sizeof(bytesize);
    if (nerr)
     nerr&=(bytesize==save_section(f,&bytesize,A_MAPEND,bytesize));
  strcpy(enpass,"Ty si \x8 ale nedas pokoj! \x8");
  bytesize=strlen(enpass)+1;
    if (nerr && bytesize>1)
      {
      encrypt(enpass);
      memcpy(enpass+bytesize,"<BLOCK>\0\x13\x80",12);bytesize+=12;
      nerr&=(bytesize==save_section(f,enpass,A_PASSW,bytesize));
      }
  bytesize=sizeof(bytesize);
    if (nerr)
     nerr&=(bytesize==save_section(f,&bytesize,A_MAPEND,bytesize));
  fclose(f);
  if (names!=NULL) release_list(names);
  {
  int x,y;
  for(x=1;x<maplen;x++)
     for(y=0;y<4;y++)
     if (mapa.sidedef[x][y].flags & 0x40000)
        if ((minfo[x].x+minfo[x].y+y)& 1) mapa.sidedef[x][y].prim-=(mapa.sidedef[x][y].prim_anim & 0xf)+1;
  }
  return (int)nerr-1;
  }
예제 #9
0
TSTR_LIST read_directory(char *mask,int view_type,int attrs)
  {
  TSTR_LIST flist;
  int index=0;
  char c[2*MAX_PATH];
  WIN32_FIND_DATA s;
  HANDLE h;
  char rc;

  flist=create_list(256);
  if (flist==NULL) return flist;
  h=FindFirstFile(mask,&s);
  if (h!=INVALID_HANDLE_VALUE)
	{
    do 
     {
     char d[MAX_PATH],*p;
     int i=0;

     if (attrs==_A_NORMAL || s.dwFileAttributes & attrs)
        {
        p=d;d[MAX_PATH-1]=0;
/*        if (view_type!=DIR_NAMES)
           {
           while (s.cFileName[i]!='.' && s.cFileName[i]!='\0' ) *p++=s.cFileName[i++];
           if (s.cFileName[i]!='\0') j=i+1;else j=i;
           while (i<8)
              {
              *p++=32;i++;
              }
           i=3;
           *p++='.';
           while (s.name[j]!='\0')
              {
              *p++=s.name[j++];
              i--;
              }
           while (i>0)
              {
              *p++=32;
              i--;
              }
           }
        else */strncpy(d,s.cFileName,MAX_PATH-1);
       switch (view_type)
          {
       case DIR_FULL:sprintf(c,"%s %10d",
                            d,
                            s.nFileSizeLow
                            );
                 break;
        case DIR_SHORT:sprintf(c,"%s %10d",d,s.nFileSizeLow);break;
        case DIR_NAMES:
        case DIR_BREIF:sprintf(c,"%s",d);break;
        }
     if (str_replace(&flist,index++,c)==NULL)
        {
        release_list(flist);
        return NULL;
        }
        }
     rc=FindNextFile(h,&s);
     }
	while (rc);
	}
  FindClose(h);
  if (flist[0]==NULL)
     {
     release_list(flist);
     return NULL;
     }
  sort_list(flist,-1);
  str_delfreelines(&flist);
  return flist;
  }