我们都很渺小💌 649344781
不要让自己的青春后悔
关注数: 58 粉丝数: 150 发帖数: 7,223 关注贴吧数: 12
(⊙_⊙) #include <stdio.h> #include <string.h> #include <ctype.h> #include "config.h" #ifdef UNIX #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <pwd.h> #endif #include "cfgfile.h" #include "options.h" #include "hiscore.h" #include "input/input.h" #include "input/keyboard.h" #include "input/joystick.h" #include "draw/draw.h" char cfgfilename[80] = CONFIG_FILENAME; static const char input_keynames[12][6] = { "left", "right", "up", "down", "a", "b", "start", "rot", "sdrop", "rot-a", "rot-b", "hdrop" }; static const char tcolor_keys[8] = "ijlostz"; void writehiscores(FILE *fp); void setcfgfilename(const char *argv0) { #ifdef UNIX struct passwd *pwd; const char *s = getenv("HOME"); if (!s && (pwd = getpwuid(getuid()))) s = pwd->pw_dir; if (s && strlen(s)+strlen(CONFIG_FILENAME) < 79) { strcpy(cfgfilename, s); strcat(cfgfilename, "/"CONFIG_FILENAME); } #else int n = strlen(argv0); do n--; while (n>=0 && argv0[n] !='\\' && argv0[n] !='/'); if (n>=0 && n+strlen(CONFIG_FILENAME) < 79) { strncpy(cfgfilename, argv0, n+1); cfgfilename[n+1] = '\0'; strcat(cfgfilename, CONFIG_FILENAME); } #endif } static int readname(const char *line, char *dest) { int i, n; if (line[0] == '[') { line++; n = 7; } else n = 11; i = 0; while (i < n && (i && line[i] == '-' || islower(line[i]) || isdigit(line[i]))) { dest[i] = line[i]; i++; } if (!i || line[i-1] == '-') return 0; dest[i] = '\0'; if (n == 7) { if (line[i] != ']') return 0; } else { while (isspace(line[i])) i++; if (line[i] != '=') return 0; } return 1; } static int readopt(const char *line, char *key, union val *val, int *tp) { char *p; if (line[0] == '\n') return 0; if (readname(line, key)) { if (line[0] == '[') return 1; if (p = strchr(line, '=')) { *tp = strtoval(p+1, val); return 1; } } return 0; } #if JOYSTICK && TWOPLAYER static void read_inputdev_player(int pl) { int i = 0; if (pl != 1 && pl != 2) return; if (sect_hd.next->name[0] == 'j') i = sect_hd.next->name[2]-'0'+1; inputdevs_player[i] = pl; } #endif static int nametokeypress_i(int i, int flags) { if (i < 6) return MVLEFT+i | flags; #ifdef JOYSTICK if (i == 6) return STARTBTN; #endif if (i == 12) return 0; return (i < 11 ? MVUP+i-7 : HARDDROP) | IN_GAME | flags; } static int nametokeypress(char *name)
1 下一页