void TileCharacter::SetChar(int index) { m_pTexture = L""; m_alt = false; m_pALT = L""; m_boundingBox = false; m_exit = false; m_spawn = false; switch(index) { case 0: Space(); break; case 1: NoSpace(); break; case 2: Removable(); break; case 3: SetExit(); break; case 4: SetSpawn(); break; default: Space(); break; } }
int Insert_Row(Table *Wh , char *rData) { Row *pre = Wh -> tail; Row *p = NULL; if (Wh -> head == NULL) p = Wh -> head = (Row *)malloc(sizeof(Row)); else p = Wh -> tail -> next = (Row *)malloc(sizeof(Row));; Wh -> tail = p; if (Wh -> tail == NULL) { NoSpace(); return -1; } p -> next = NULL; p -> info = (void **)malloc(Wh -> NoC * sizeof(void *)); //指针数组 用来储存每一行的数据 if (p -> info == NULL) { NoSpace(); return -1; } for (int i = 0 ; i < Wh -> NoC ; i ++) { if (Wh -> types[i] == FLOAT) p -> info[i] = (void *)malloc(sizeof(double)); else p -> info[i] = (void *)malloc(Wh ->types[i] * sizeof(char)); if (p -> info[i] == NULL) { NoSpace(); return -1; } } p -> select = 0; char *tmp = (char *)malloc(MAXLEN * sizeof(char)); if (tmp == NULL) { NoSpace(); return -1; } char *tmp_bac = tmp; int index = 0; for ( ; *rData != '\0' ; rData ++) //每碰到一个逗号就处理这个区间的数据 { if (*rData == ',' || *rData == '\n') { *tmp = '\0'; if (*tmp_bac == '\0' && Wh -> null[index] == NOT_NULL) //如果该列值为空 但是建表时要求不能为空 则error { if (pre == NULL) Wh -> head = NULL; else Wh -> tail = pre; printf("---The column '%s' can not be empty.---\n" , Wh -> names[index]); return -1; } if (Wh -> types[index] == 0) *((double *)(p -> info[index])) = atof(tmp_bac); else Strcopy((char *)(p -> info[index]) , tmp_bac); index ++; tmp = tmp_bac; } else *(tmp ++) = *rData; } return 0; }