Mercurial > hg > old > magoroku_racing
changeset 138:993d5f7e5f30
collision
malloc error after face reading
author | e085768 |
---|---|
date | Fri, 22 Jul 2011 23:51:14 +0900 |
parents | 298825d8837f |
children | dbf8858aceed |
files | Makefile Ss.o car.cc col.cc field.cc game_time.o getStrFromFile.cc libps2.h schedule.cc sjoy.o sound.o |
diffstat | 11 files changed, 27 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Fri Jul 22 18:43:45 2011 +0900 +++ b/Makefile Fri Jul 22 23:51:14 2011 +0900 @@ -5,7 +5,7 @@ ABI = -m$(ABIBIT) SRCS = game.cc car.cc col.cc quotanion.cc controler.cc field.cc camera.cc gSprite.cc schedule.cc mytype.cc gFont.cc carNode.cc light.cc title_scene.cc game_time.cc ps2util.cc sjoy.cc name_dictionary.cc sound.cc Ss.cc getStrFromFile.cc - +TEST_SRCS = col.cc ps2util.cc gSprite.cc #CFLAGS += -DINVISIBLE_MODE -g $(ABI) -Wall `sdl-config --cflags` `xml2-config --cflags` $(INCLUDE) CFLAGS += -DINVISIBLE_MODE -g -O0 $(ABI) -Wall `sdl-config --cflags` `xml2-config --cflags` `freetype-config --cflags` $(INCLUDE) @@ -17,13 +17,16 @@ #TEST = test_vector OBJS = ${SRCS:.cc=.o} - +TEST_OBJS = ${TEST_SRCS:.cc=.o} all: $(TARGET) #${TEST} magoroku: $(OBJS) Magoroku.o $(CC) $(ABI) -o $@ $(OBJS) Magoroku.o $(LIBS) +test_collision: $(TEST_OBJS) test_collision.o + $(CC) $(ABI) -o $@ $(TEST_OBJS) test_collision.o $(LIBS) + #${TEST}: ps2util.o test_vector.o # ${CC} $(ABI) -o test_vector.o ps2util.o $(LIBS) # $(CC) -o test_vector.o
--- a/car.cc Fri Jul 22 18:43:45 2011 +0900 +++ b/car.cc Fri Jul 22 23:51:14 2011 +0900 @@ -19,7 +19,8 @@ #define BUFSIZE 256 /* 初期位置と初期方向 */ -static FVECTOR location = {0, 0, 5, 1}; +static FVECTOR location = {0, 0, 0, 1}; + static FVECTOR direction = {0, 0, 1, 1}; extern FILE* main_fp; @@ -49,9 +50,9 @@ body->partNum = getStrFromFile( body->partName, filename, sStr, eStr ); /* - for( int i = 0; i < body->partNum; i ++ ){ + for( int i = 0; i < body->partNum; i ++ ){ gSprite_DefSprite( 100, body->partName[i], 919, 666, 1); - } + } */ // 初期化 // createScenGraph関数の引数アリと無しの違いは? @@ -307,14 +308,13 @@ car->body->xyz[1] = -car->location[1]; car->body->xyz[2] = -car->location[2]; - // いまちょっとコメントアウト // 壁にぶつかった時の処理 if (car_field_check(game,car) == false) { // 壁にぶつかったら計算前の前フレームの座標にしてsppedは半分 ps2_vu0_copy_vector(car->location, prev_location); car->speed = car->speed*0.5; printf("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); - printf("^^^^^^collision!!!!!^^^^^^^^^\n"); + printf("^^^^^^courseOUT!!!!!^^^^^^^^^\n"); } }
--- a/col.cc Fri Jul 22 18:43:45 2011 +0900 +++ b/col.cc Fri Jul 22 23:51:14 2011 +0900 @@ -130,7 +130,8 @@ malloc_align16(&hd->free_addr, &colface, sizeof(ColFace)*face->pp_num); - hd->facenum = face->pp_num; + hd->facenum = face->size/3; + for (i=0; i < hd->facenum; i++) { memcpy(colface[i].p0, &face->pp->tri[i].ver1, sizeof(FVECTOR));
--- a/field.cc Fri Jul 22 18:43:45 2011 +0900 +++ b/field.cc Fri Jul 22 23:51:14 2011 +0900 @@ -61,8 +61,8 @@ call_createFromXMLfile(fieldImg); /*sStr から eStrまでの間の文字列を取得する */ - const char *sStr = "surface name=\""; - const char *eStr = "\" size="; + static const char *sStr = "surface name=\""; + static const char *eStr = "\" size="; // xmlファイルから surface name と 数を取得する obj->partNum = getStrFromFile( obj->partName, fieldImg, sStr, eStr );
--- a/getStrFromFile.cc Fri Jul 22 18:43:45 2011 +0900 +++ b/getStrFromFile.cc Fri Jul 22 23:51:14 2011 +0900 @@ -46,15 +46,15 @@ int p2Len = strlen(p2); // // 余分なsearchEndStr以降の文字列を切り捨てるため空白文字(改行文字だっけ?'\0'ってなんだっけ) - p1[p1Len - p2Len] = '\0'; - + //p1[p1Len - p2Len] = '\0'; + p2 = '\0'; int searchStartStrLen = strlen(searchStartStr); // +searchStartStrLenで最初の余分な文字列をカウントしないようにする int lenNum = strlen(p1 + searchStartStrLen); // 動的にメモリ確保したい。なんかオカしいってのはわかるケド、良い方法が思いつかん - getStrDate[num] = (char*)malloc(sizeof(char)*lenNum); + getStrDate[num] = (char*)malloc(sizeof(char)*lenNum+1); strcpy(getStrDate[num], p1+searchStartStrLen);
--- a/libps2.h Fri Jul 22 18:43:45 2011 +0900 +++ b/libps2.h Fri Jul 22 23:51:14 2011 +0900 @@ -2,7 +2,7 @@ #ifndef LIBPS2_H #define LIBPS2_H -#include "SceneGraph.h" +//#include "SceneGraph.h" //dummy file
--- a/schedule.cc Fri Jul 22 18:43:45 2011 +0900 +++ b/schedule.cc Fri Jul 22 23:51:14 2011 +0900 @@ -357,6 +357,15 @@ set_schedule_assumption(sche_game_main_ready); + ColFacePtr colface = field_get_actual( )->colface.colface; + + + INIT_VECTOR(game->jiki->location, + (3*colface->p0[0]+colface->v0[0]+colface->v1[0])/3, + (3*colface->p0[1]+colface->v0[1]+colface->v1[1])/3, + (3*colface->p0[2]+colface->v0[2]+colface->v1[2])/3, 1); + + // とりあえず、トップビューで // FVECTOR cPos = { 0, 877, -2000, 0 }; FVECTOR cPos = { 0, 877, 7500, 0 };