diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2018-03-19 19:56:15 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2018-03-19 19:56:15 +0100 |
commit | 1542c122b3672fe83e027411ad2445772e2d0ed3 (patch) | |
tree | e535bc621bd7ffa9d5ce89e0d495df5d1c4ab6fd /app/bin/dcar.c | |
parent | 773810e6583142d7d15263e6481c42aebed6d7f1 (diff) | |
parent | d1a8285f818eb7e5c3d6a05709ea21a808490b8c (diff) |
Update upstream source from tag 'upstream/5.1.0'
Update to upstream version '5.1.0'
with Debian dir 93ca74b8b4602fce4c9c7740e0cfdde25f086673
Diffstat (limited to 'app/bin/dcar.c')
-rw-r--r-- | app/bin/dcar.c | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/app/bin/dcar.c b/app/bin/dcar.c index c64582f..9236f1b 100644 --- a/app/bin/dcar.c +++ b/app/bin/dcar.c @@ -1,6 +1,5 @@ /** \file dcar.c * TRAIN - * */ /* XTrkCad - Model Railroad CAD @@ -24,14 +23,23 @@ #ifndef WINDOWS #include <errno.h> #endif +#include <assert.h> #include <ctype.h> - +#include <math.h> #include <stdint.h> +#include <string.h> -#include "track.h" +#include "cselect.h" #include "ctrain.h" -#include "i18n.h" +#include "custom.h" #include "fileio.h" +#include "i18n.h" +#include "layout.h" +#include "messages.h" +#include "param.h" +#include "paths.h" +#include "track.h" +#include "utility.h" static int log_carList; static int log_carInvList; @@ -626,6 +634,8 @@ static carProto_p CarProtoNew( proto->type = type; proto->dim = *dim; proto->segCnt = segCnt; + //if (proto->segPtr) Can't do this because segPtr could be static + // free(proto->segPtr); proto->segPtr = (trkSeg_p)memdup( segPtr, (sizeof *(trkSeg_p)0) * proto->segCnt ); CloneFilledDraw( proto->segCnt, proto->segPtr, FALSE ); GetSegBounds( zero, 0.0, proto->segCnt, proto->segPtr, &proto->orig, &proto->size ); @@ -660,6 +670,8 @@ static BOOL_T CarProtoRead( if ( !ReadSegs() ) return FALSE; CarProtoNew( NULL, curParamFileIndex, desc, options, type, &dim, tempSegs_da.cnt, &tempSegs(0) ); + FreeFilledDraw(tempSegs_da.cnt,&tempSegs(0)); + MyFree(desc); return TRUE; } @@ -1255,7 +1267,7 @@ static BOOL_T CarItemWrite( item->data.purchPrice, item->data.currPrice, item->data.condition, item->data.purchDate, item->data.serviceDate )>0; if ( ( options&CAR_ITEM_ONLAYOUT) ) { CarGetPos( item->car, &pos, &angle ); - rc &= fprintf( f, " %d %d %0.3f %0.3f %0.3f", + rc &= fprintf( f, " %d %u %0.3f %0.3f %0.3f", GetTrkIndex(item->car), GetTrkLayer(item->car), pos.x, pos.y, angle )>0; } rc &= fprintf( f, "\n" )>0; @@ -1614,7 +1626,7 @@ EXPORT int CarAvailableCount( void ) carItem_t * item; for ( inx=0; inx < carItemHotbar_da.cnt; inx ++ ) { item = carItemHotbar(inx); - if ( item->scaleInx != curScaleInx ) + if ( item->scaleInx != GetLayoutCurScale()) continue; cnt++; } @@ -1636,7 +1648,7 @@ EXPORT void AddHotBarCarDesc( void ) item1 = carItemHotbar(inx); if ( item1->car && !IsTrackDeleted(item1->car) ) continue; - if ( item1->scaleInx != curScaleInx ) + if ( item1->scaleInx != GetLayoutCurScale()) continue; if ( (carHotbarModes[carHotbarModeInx]&0xF000)!=0 || ( item0 == NULL || Cmp_carHotbar( &item0, &item1 ) != 0 ) ) { #ifdef DESCFIX @@ -3811,7 +3823,7 @@ LOG( log_carDlgState, 3, ( "CarDlgOk()\n" ) ) sprintf( message+strlen(message), "%s: %s %s %s %s %s %s", (partP?_(" and Part"):""), carDlgManufStr, carDlgPartnoStr, carDlgProtoStr, carDlgDescStr, - (carDlgRepmarkStr?carDlgRepmarkStr:carDlgRoadnameStr), carDlgNumberStr ); + (carDlgRepmarkStr[ 0 ]?carDlgRepmarkStr:carDlgRoadnameStr), carDlgNumberStr ); carDlgQuantity = 1; ParamLoadControl( &carDlgPG, I_CD_QTY ); @@ -3836,7 +3848,7 @@ LOG( log_carDlgState, 3, ( "CarDlgOk()\n" ) ) RestoreLocale(oldLocale); } reloadRoadnameList = TRUE; - sprintf( message, _("%s Part: %s %s %s %s %s %s"), carDlgUpdatePartPtr==NULL?_("Added new"):_("Updated"), carDlgManufStr, carDlgPartnoStr, carDlgProtoStr, carDlgDescStr, carDlgRepmarkStr?carDlgRepmarkStr:carDlgRoadnameStr, carDlgNumberStr ); + sprintf( message, _("%s Part: %s %s %s %s %s %s"), carDlgUpdatePartPtr==NULL?_("Added new"):_("Updated"), carDlgManufStr, carDlgPartnoStr, carDlgProtoStr, carDlgDescStr, carDlgRepmarkStr[ 0 ]?carDlgRepmarkStr:carDlgRoadnameStr, carDlgNumberStr ); } else if ( S_PROTO ) { if ( carDlgUpdateProtoPtr==NULL ) { @@ -3876,7 +3888,7 @@ LOG( log_carDlgState, 3, ( "CarDlgOk()\n" ) ) if ( carDlgUpdateItemPtr==NULL ) { if ( partP ) { TabStringExtract( title, 7, tabs ); - if ( CarDlgLoadLists( TRUE, tabs, curScaleInx ) ) + if ( CarDlgLoadLists( TRUE, tabs, GetLayoutCurScale()) ) currState = S_ItemSel; else currState = S_ItemEnter; @@ -4003,7 +4015,7 @@ static void DoCarPartDlg( carDlgAction_e *actions ) CarDlgLoadRoadnameList(); carProtoSegCnt = 0; carProtoSegPtr = NULL; - carDlgScaleInx = curScaleInx; + carDlgScaleInx = GetLayoutCurScale(); carDlgFlipToggle = FALSE; carDlgChanged = 0; @@ -4135,12 +4147,13 @@ static void CarInvDlgFind( void * junk ) if ( item == NULL || item->car == NULL || IsTrackDeleted(item->car) ) return; CarGetPos( item->car, &pos, &angle ); CarSetVisible( item->car ); - DrawMapBoundingBox( FALSE ); + //DrawMapBoundingBox( FALSE ); mainCenter = pos; mainD.orig.x = pos.x-mainD.size.x/2;; mainD.orig.y = pos.y-mainD.size.y/2;; MainRedraw(); - DrawMapBoundingBox( TRUE ); + MapRedraw(); + //DrawMapBoundingBox( TRUE ); } @@ -4345,7 +4358,7 @@ static void CarInvDlgSaveText( void ) if ( carInvSaveText_fs == NULL ) carInvSaveText_fs = wFilSelCreate( mainW, FS_SAVE, 0, _("List Cars"), "Text|*.txt", CarInvSaveText, NULL ); - wFilSelect( carInvSaveText_fs, curDirName ); + wFilSelect( carInvSaveText_fs, GetCurrentPath(CARSPATHKEY)); } @@ -4630,7 +4643,7 @@ static void CarInvDlgImportCsv( void ) if ( carInvImportCsv_fs == NULL ) carInvImportCsv_fs = wFilSelCreate( mainW, FS_LOAD, 0, _("Import Cars"), _("Comma-Separated-Values|*.csv"), CarInvImportCsv, NULL ); - wFilSelect( carInvImportCsv_fs, curDirName ); + wFilSelect( carInvImportCsv_fs, GetCurrentPath(CARSPATHKEY)); } @@ -4752,7 +4765,7 @@ static void CarInvDlgExportCsv( void ) if ( carInvExportCsv_fs == NULL ) carInvExportCsv_fs = wFilSelCreate( mainW, FS_SAVE, 0, _("Export Cars"), _("Comma-Separated-Values|*.csv"), CarInvExportCsv, NULL ); - wFilSelect( carInvExportCsv_fs, curDirName ); + wFilSelect( carInvExportCsv_fs, GetCurrentPath(CARSPATHKEY)); } |