From 3ee033eeeb2d9a0e4977747188116c342b0f1dd0 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 27 Sep 2016 21:32:55 +0200 Subject: [PATCH 1/5] Write texture types when pview failed to recognise extension --- panda/src/framework/windowFramework.cxx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/panda/src/framework/windowFramework.cxx b/panda/src/framework/windowFramework.cxx index 9f4ea1eecb..9f808d5d78 100644 --- a/panda/src/framework/windowFramework.cxx +++ b/panda/src/framework/windowFramework.cxx @@ -639,10 +639,13 @@ load_model(const NodePath &parent, Filename filename) { extension = Filename(filename.get_basename_wo_extension()).get_extension(); } #endif // HAVE_ZLIB + TexturePool *texture_pool = TexturePool::get_global_ptr(); + LoaderFileType *model_type = NULL; + if (!extension.empty()) { LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr(); - LoaderFileType *model_type = - reg->get_type_from_extension(extension); + model_type = reg->get_type_from_extension(extension); + if (model_type == (LoaderFileType *)NULL) { // The extension isn't a known model file type; is it a known // image file extension? @@ -652,7 +655,6 @@ load_model(const NodePath &parent, Filename filename) { is_image = true; } else { - TexturePool *texture_pool = TexturePool::get_global_ptr(); if (texture_pool->get_texture_type(extension) != NULL) { // It is a known image file extension. is_image = true; @@ -674,6 +676,13 @@ load_model(const NodePath &parent, Filename filename) { node = load_image_as_model(filename); } else { node = loader.load_sync(filename, options); + + // It failed to load. Is it because the extension isn't recognised? If + // so, then we just got done printing out the known scene types, and we + // should also print out the supported texture types. + if (node == (PandaNode *)NULL && !is_image && model_type == NULL) { + texture_pool->write_texture_types(nout, 2); + } } if (node == (PandaNode *)NULL) { From aa74caacbe92ff987691c99adeaaf18659673b90 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 27 Sep 2016 21:35:38 +0200 Subject: [PATCH 2/5] Fix inoperative -tbn/-tbnall/-tbnauto options in egg-optchar --- doc/ReleaseNotes | 1 + pandatool/src/eggbase/eggMultiBase.cxx | 27 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 1da0320973..ce390136fc 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -37,6 +37,7 @@ This issue fixes several bugs that were still found in 1.9.2. * Fix asyncFlattenStrong called on nodes without parent * Fix is_playing() check when playing an animation backwards * Windows installer no longer clears %PATH% if longer than 1024 chars +* Fix inoperative -tbn/-tbnall/-tbnauto options in egg-optchar ------------------------ RELEASE 1.9.2 ------------------------ diff --git a/pandatool/src/eggbase/eggMultiBase.cxx b/pandatool/src/eggbase/eggMultiBase.cxx index 27513e6dfe..1f1a0e3bea 100644 --- a/pandatool/src/eggbase/eggMultiBase.cxx +++ b/pandatool/src/eggbase/eggMultiBase.cxx @@ -111,6 +111,33 @@ post_process_egg_files() { // Do nothing. break; } + + if (_got_tbnall) { + for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) { + if ((*ei)->recompute_tangent_binormal(GlobPattern("*"))) { + (*ei)->remove_unused_vertices(true); + } + } + } else { + if (_got_tbnauto) { + for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) { + if ((*ei)->recompute_tangent_binormal_auto()) { + (*ei)->remove_unused_vertices(true); + } + } + } + + for (vector_string::const_iterator si = _tbn_names.begin(); + si != _tbn_names.end(); + ++si) { + GlobPattern uv_name(*si); + nout << "Computing tangent and binormal for \"" << uv_name << "\"\n"; + for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) { + (*ei)->recompute_tangent_binormal(uv_name); + (*ei)->remove_unused_vertices(true); + } + } + } } From 2e9394eba70f049d632684f78f7ef94b2d3ca00b Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 27 Sep 2016 22:37:13 +0200 Subject: [PATCH 3/5] Fix tinydisplay texture errors on shutdown --- doc/ReleaseNotes | 1 + .../tinydisplay/tinyGraphicsStateGuardian.cxx | 17 +--------------- panda/src/tinydisplay/tinyTextureContext.I | 10 ---------- panda/src/tinydisplay/tinyTextureContext.cxx | 20 +++++++++++++++++++ panda/src/tinydisplay/tinyTextureContext.h | 2 +- 5 files changed, 23 insertions(+), 27 deletions(-) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index ce390136fc..5b0b4c6478 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -38,6 +38,7 @@ This issue fixes several bugs that were still found in 1.9.2. * Fix is_playing() check when playing an animation backwards * Windows installer no longer clears %PATH% if longer than 1024 chars * Fix inoperative -tbn/-tbnall/-tbnauto options in egg-optchar +* Fix tinydisplay texture errors on shutdown ------------------------ RELEASE 1.9.2 ------------------------ diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index b9efe215c5..4e865ad855 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -1800,24 +1800,9 @@ update_texture(TextureContext *tc, bool force, int stage_index, bool uses_mipmap //////////////////////////////////////////////////////////////////// void TinyGraphicsStateGuardian:: release_texture(TextureContext *tc) { - TinyTextureContext *gtc = DCAST(TinyTextureContext, tc); - _texturing_state = 0; // just in case - GLTexture *gltex = >c->_gltex; - if (gltex->allocated_buffer != NULL) { - nassertv(gltex->num_levels != 0); - TinyTextureContext::get_class_type().dec_memory_usage(TypeHandle::MC_array, gltex->total_bytecount); - PANDA_FREE_ARRAY(gltex->allocated_buffer); - gltex->allocated_buffer = NULL; - gltex->total_bytecount = 0; - gltex->num_levels = 0; - } else { - nassertv(gltex->num_levels == 0); - } - - gtc->dequeue_lru(); - + TinyTextureContext *gtc = DCAST(TinyTextureContext, tc); delete gtc; } diff --git a/panda/src/tinydisplay/tinyTextureContext.I b/panda/src/tinydisplay/tinyTextureContext.I index ef223f668a..40545856a7 100644 --- a/panda/src/tinydisplay/tinyTextureContext.I +++ b/panda/src/tinydisplay/tinyTextureContext.I @@ -26,13 +26,3 @@ TinyTextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view) : _gltex.allocated_buffer = NULL; _gltex.total_bytecount = 0; } - -//////////////////////////////////////////////////////////////////// -// Function: TinyTextureContext::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE TinyTextureContext:: -~TinyTextureContext() { - nassertv(_gltex.num_levels == 0 && _gltex.allocated_buffer == NULL && _gltex.total_bytecount == 0); -} diff --git a/panda/src/tinydisplay/tinyTextureContext.cxx b/panda/src/tinydisplay/tinyTextureContext.cxx index 3addd211ff..eba0a3ea63 100644 --- a/panda/src/tinydisplay/tinyTextureContext.cxx +++ b/panda/src/tinydisplay/tinyTextureContext.cxx @@ -17,6 +17,26 @@ TypeHandle TinyTextureContext::_type_handle; +//////////////////////////////////////////////////////////////////// +// Function: TinyTextureContext::Destructor +// Access: Public +// Description: Releases the memory associated with the texture. +//////////////////////////////////////////////////////////////////// +TinyTextureContext:: +~TinyTextureContext() { + GLTexture *gltex = &_gltex; + if (gltex->allocated_buffer != NULL) { + nassertv(gltex->num_levels != 0); + TinyTextureContext::get_class_type().dec_memory_usage(TypeHandle::MC_array, gltex->total_bytecount); + PANDA_FREE_ARRAY(gltex->allocated_buffer); + gltex->allocated_buffer = NULL; + gltex->total_bytecount = 0; + gltex->num_levels = 0; + } else { + nassertv(gltex->num_levels == 0); + } +} + //////////////////////////////////////////////////////////////////// // Function: TinyTextureContext::evict_lru // Access: Public, Virtual diff --git a/panda/src/tinydisplay/tinyTextureContext.h b/panda/src/tinydisplay/tinyTextureContext.h index e98547bc0e..13da745e14 100644 --- a/panda/src/tinydisplay/tinyTextureContext.h +++ b/panda/src/tinydisplay/tinyTextureContext.h @@ -29,7 +29,7 @@ public: INLINE TinyTextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view); ALLOC_DELETED_CHAIN(TinyTextureContext); - INLINE ~TinyTextureContext(); + ~TinyTextureContext(); virtual void evict_lru(); From 3f5399437221259bf0940e9bb2d3eb1d4e3ece42 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 28 Sep 2016 00:00:22 +0200 Subject: [PATCH 4/5] Fix mipmap filtering issues in tinydisplay renderer --- doc/ReleaseNotes | 1 + panda/src/tinydisplay/zbuffer.cxx | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 5b0b4c6478..0728f34023 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -39,6 +39,7 @@ This issue fixes several bugs that were still found in 1.9.2. * Windows installer no longer clears %PATH% if longer than 1024 chars * Fix inoperative -tbn/-tbnall/-tbnauto options in egg-optchar * Fix tinydisplay texture errors on shutdown +* Fix mipmap filtering issues in tinydisplay renderer ------------------------ RELEASE 1.9.2 ------------------------ diff --git a/panda/src/tinydisplay/zbuffer.cxx b/panda/src/tinydisplay/zbuffer.cxx index 4623a85353..cc25320646 100644 --- a/panda/src/tinydisplay/zbuffer.cxx +++ b/panda/src/tinydisplay/zbuffer.cxx @@ -489,11 +489,11 @@ lookup_texture_mipmap_linear(ZTextureDef *texture_def, int s, int t, unsigned in level = max((int)level - 1, 0); p2 = ZB_LOOKUP_TEXTURE_MIPMAP_NEAREST(texture_def, s, t, level); - unsigned int bitsize = level + ZB_POINT_ST_FRAC_BITS; - r = LINEAR_FILTER_BITSIZE(PIXEL_R(p2), PIXEL_R(p1), level_dx, bitsize); - g = LINEAR_FILTER_BITSIZE(PIXEL_G(p2), PIXEL_G(p1), level_dx, bitsize); - b = LINEAR_FILTER_BITSIZE(PIXEL_B(p2), PIXEL_B(p1), level_dx, bitsize); - a = LINEAR_FILTER_BITSIZE(PIXEL_A(p2), PIXEL_A(p1), level_dx, bitsize); + unsigned int f = level_dx >> (level - 1); + r = LINEAR_FILTER(PIXEL_R(p1), PIXEL_R(p2), f); + g = LINEAR_FILTER(PIXEL_G(p1), PIXEL_G(p2), f); + b = LINEAR_FILTER(PIXEL_B(p1), PIXEL_B(p2), f); + a = LINEAR_FILTER(PIXEL_A(p1), PIXEL_A(p2), f); return RGBA_TO_PIXEL(r, g, b, a); } @@ -570,11 +570,11 @@ lookup_texture_mipmap_trilinear(ZTextureDef *texture_def, int s, int t, unsigned } int r, g, b, a; - unsigned int bitsize = level + ZB_POINT_ST_FRAC_BITS; - r = LINEAR_FILTER_BITSIZE(PIXEL_R(p2a), PIXEL_R(p1a), level_dx, bitsize); - g = LINEAR_FILTER_BITSIZE(PIXEL_G(p2a), PIXEL_G(p1a), level_dx, bitsize); - b = LINEAR_FILTER_BITSIZE(PIXEL_B(p2a), PIXEL_B(p1a), level_dx, bitsize); - a = LINEAR_FILTER_BITSIZE(PIXEL_A(p2a), PIXEL_A(p1a), level_dx, bitsize); + unsigned int f = level_dx >> (level - 1); + r = LINEAR_FILTER(PIXEL_R(p1a), PIXEL_R(p2a), f); + g = LINEAR_FILTER(PIXEL_G(p1a), PIXEL_G(p2a), f); + b = LINEAR_FILTER(PIXEL_B(p1a), PIXEL_B(p2a), f); + a = LINEAR_FILTER(PIXEL_A(p1a), PIXEL_A(p2a), f); return RGBA_TO_PIXEL(r, g, b, a); } From 231ca47edd20c8576df6cb94f656579160cd1fdf Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 28 Sep 2016 00:08:28 +0200 Subject: [PATCH 5/5] Windows installer: More robust and less error-prone PATH changing --- makepanda/installer.nsi | 317 +++++++++++----------------------------- 1 file changed, 87 insertions(+), 230 deletions(-) diff --git a/makepanda/installer.nsi b/makepanda/installer.nsi index 8203954cf6..fa504d99c8 100755 --- a/makepanda/installer.nsi +++ b/makepanda/installer.nsi @@ -886,17 +886,16 @@ Function AddToPath Goto AddToPath_done AddToPath_NT: + ClearErrors ReadRegStr $1 HKCU "Environment" "PATH" - Call IsUserAdmin - Pop $3 - ; If this is an Admin user, use the System env. variable instead of the user's env. variable - StrCmp $3 1 0 +2 - ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" - ; If the PATH string is empty, WATCH OUT. This probably means - ; the PATH surpassed NSIS' string limit. Don't overwrite it! - ; The only thing we can do is display an error message. - StrCmp $1 "" AddToPath_EmptyError + ; If we reached an error, WATCH OUT. Either this means that + ; the registry key did not exist, or that it didn't fit in + ; NSIS' string limit. If the latter, we have to be very + ; careful not to overwrite the user's PATH. + IfErrors AddToPath_Error + DetailPrint "Current PATH value is set to $1" + StrCmp $1 "" AddToPath_NTAddPath ; Pull off the last character of the PATH string. If it's a semicolon, ; we don't need to add another one, so jump to the section where we @@ -904,7 +903,20 @@ Function AddToPath StrCpy $2 $1 1 -1 StrCmp $2 ";" AddToPath_NTAddPath AddToPath_NTAddSemi - AddToPath_EmptyError: + AddToPath_Error: + DetailPrint "Encountered error reading PATH variable." + ; Does the variable exist? If it doesn't, then the + ; error happened because we need to create the + ; variable. If it does, then we failed to read it + ; because we reached NSIS' string limit. + StrCpy $3 0 + AddToPath_loop: + EnumRegValue $4 HKCU "Environment" $3 + StrCmp $4 "PATH" AddToPath_ExceedLimit + StrCmp $4 "" AddToPath_NTAddPath + IntOp $3 $3 + 1 + Goto AddToPath_loop + AddToPath_ExceedLimit: MessageBox MB_ABORTRETRYIGNORE|MB_ICONEXCLAMATION "Your PATH environment variable is too long! Please remove extraneous entries before proceeding. Panda3D needs to add the following the PATH so that the Panda3D utilities and libraries can be located correctly.$\n$\n$0$\n$\nIf you wish to add Panda3D to the path yourself, choose Ignore." IDIGNORE AddToPath_done IDRETRY AddToPath_NT SetDetailsPrint both DetailPrint "Cannot append to PATH - variable is likely too long." @@ -915,16 +927,7 @@ Function AddToPath Goto AddToPath_NTAddPath AddToPath_NTAddPath: StrCpy $0 "$1$0" - Goto AddToPath_NTdoIt - AddToPath_NTdoIt: - Call IsUserAdmin - Pop $3 - StrCmp $3 1 0 NotAdmin - WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $0 - Goto AddToPath_done - - NotAdmin: - WriteRegExpandStr HKCU "Environment" "PATH" $0 + WriteRegExpandStr HKCU "Environment" "PATH" $0 AddToPath_done: Pop $3 Pop $2 @@ -975,42 +978,40 @@ Function RemoveFromPath Goto unRemoveFromPath_done unRemoveFromPath_NT: + Push $0 StrLen $2 $0 - Call IsUserAdmin - Pop $5 - StrCmp $5 1 0 NotAdmin - ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" - Push $1 - Push $0 - Call StrStr ; Find $0 in $1 - Pop $0 ; pos of our dir - IntCmp $0 -1 unRemoveFromPath_done - ; else, it is in path - StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir - IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';') - IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon. - StrLen $0 $1 - StrCpy $1 $1 $0 $2 - StrCpy $3 "$3$1" - WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $3 - Goto unRemoveFromPath_done + ReadRegStr $1 HKCU "Environment" "PATH" + Push $1 + Push $0 + Call StrStr ; Find $0 in $1 + Pop $0 ; pos of our dir + IntCmp $0 -1 unRemoveFromPath_NT_System + ; else, it is in path + StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir + IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';') + IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon. + StrLen $0 $1 + StrCpy $1 $1 $0 $2 + StrCpy $3 "$3$1" + WriteRegExpandStr HKCU "Environment" "PATH" $3 - - NotAdmin: - ReadRegStr $1 HKCU "Environment" "PATH" - Push $1 - Push $0 - Call StrStr ; Find $0 in $1 - Pop $0 ; pos of our dir - IntCmp $0 -1 unRemoveFromPath_done - ; else, it is in path - StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir - IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';') - IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon. - StrLen $0 $1 - StrCpy $1 $1 $0 $2 - StrCpy $3 "$3$1" - WriteRegExpandStr HKCU "Environment" "PATH" $3 + unRemoveFromPath_NT_System: + Pop $0 + StrLen $2 $0 + ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" + Push $1 + Push $0 + Call StrStr ; Find $0 in $1 + Pop $0 ; pos of our dir + IntCmp $0 -1 unRemoveFromPath_done + ; else, it is in path + StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir + IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';') + IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon. + StrLen $0 $1 + StrCpy $1 $1 $0 $2 + StrCpy $3 "$3$1" + WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $3 unRemoveFromPath_done: Pop $5 @@ -1061,42 +1062,40 @@ Function un.RemoveFromPath Goto unRemoveFromPath_done unRemoveFromPath_NT: + Push $0 StrLen $2 $0 - Call un.IsUserAdmin - Pop $5 - StrCmp $5 1 0 NotAdmin - ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" - Push $1 - Push $0 - Call un.StrStr ; Find $0 in $1 - Pop $0 ; pos of our dir - IntCmp $0 -1 unRemoveFromPath_done - ; else, it is in path - StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir - IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';') - IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon. - StrLen $0 $1 - StrCpy $1 $1 $0 $2 - StrCpy $3 "$3$1" - WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $3 - Goto unRemoveFromPath_done + ReadRegStr $1 HKCU "Environment" "PATH" + Push $1 + Push $0 + Call un.StrStr ; Find $0 in $1 + Pop $0 ; pos of our dir + IntCmp $0 -1 unRemoveFromPath_NT_System + ; else, it is in path + StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir + IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';') + IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon. + StrLen $0 $1 + StrCpy $1 $1 $0 $2 + StrCpy $3 "$3$1" + WriteRegExpandStr HKCU "Environment" "PATH" $3 - - NotAdmin: - ReadRegStr $1 HKCU "Environment" "PATH" - Push $1 - Push $0 - Call un.StrStr ; Find $0 in $1 - Pop $0 ; pos of our dir - IntCmp $0 -1 unRemoveFromPath_done - ; else, it is in path - StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir - IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';') - IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon. - StrLen $0 $1 - StrCpy $1 $1 $0 $2 - StrCpy $3 "$3$1" - WriteRegExpandStr HKCU "Environment" "PATH" $3 + unRemoveFromPath_NT_System: + Pop $0 + StrLen $2 $0 + ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" + Push $1 + Push $0 + Call un.StrStr ; Find $0 in $1 + Pop $0 ; pos of our dir + IntCmp $0 -1 unRemoveFromPath_done + ; else, it is in path + StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir + IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';') + IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon. + StrLen $0 $1 + StrCpy $1 $1 $0 $2 + StrCpy $3 "$3$1" + WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $3 unRemoveFromPath_done: Pop $5 @@ -1107,148 +1106,6 @@ Function un.RemoveFromPath Pop $0 FunctionEnd -; From: http://nsis.sourceforge.net/archive/nsisweb.php?page=329&instances=0,11 -; Localized by Ben Johnson (bkj@andrew.cmu.edu) -Function IsUserAdmin - Push $0 - Push $1 - Push $2 - Push $3 - Call IsNT - Pop $1 - - ClearErrors - UserInfo::GetName - ;IfErrors Win9x - Pop $2 - UserInfo::GetAccountType - Pop $3 - - ; Compare results of IsNT with "1" - StrCmp $1 1 0 NotNT - ;This is NT - - - StrCmp $3 "Admin" 0 NotAdmin - ; Observation: I get here when running Win98SE. (Lilla) - ; The functions UserInfo.dll looks for are there on Win98 too, - ; but just don't work. So UserInfo.dll, knowing that admin isn't required - ; on Win98, returns admin anyway. (per kichik) - ; MessageBox MB_OK 'User "$R1" is in the Administrators group' - Pop $3 - Pop $2 - Pop $1 - Pop $0 - - Push 1 - Return - - NotAdmin: - ; You should still check for an empty string because the functions - ; UserInfo.dll looks for may not be present on Windows 95. (per kichik) - - #StrCmp $2 "" Win9x - #StrCpy $0 0 - ;MessageBox MB_OK 'User "$2" is in the "$3" group' - Pop $3 - Pop $2 - Pop $1 - Pop $0 - - Push 0 - Return - - ;Because we use IsNT, this is redundant. - #Win9x: - # ; comment/message below is by UserInfo.nsi author: - # ; This one means you don't need to care about admin or - # ; not admin because Windows 9x doesn't either - # ;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!" - # StrCpy $0 0 - - NotNT: - ;We are not NT - ;Win9x doesn't have "admin" users. - ;Let the user do whatever. - Pop $3 - Pop $2 - Pop $1 - Pop $0 - - Push 1 - -FunctionEnd - -Function un.IsUserAdmin - Push $0 - Push $1 - Push $2 - Push $3 - Call un.IsNT - Pop $1 - - ClearErrors - UserInfo::GetName - ;IfErrors Win9x - Pop $2 - UserInfo::GetAccountType - Pop $3 - - ; Compare results of IsNT with "1" - StrCmp $1 1 0 NotNT - ;This is NT - - - StrCmp $3 "Admin" 0 NotAdmin - ; Observation: I get here when running Win98SE. (Lilla) - ; The functions UserInfo.dll looks for are there on Win98 too, - ; but just don't work. So UserInfo.dll, knowing that admin isn't required - ; on Win98, returns admin anyway. (per kichik) - ; MessageBox MB_OK 'User "$R1" is in the Administrators group' - Pop $3 - Pop $2 - Pop $1 - Pop $0 - - Push 1 - Return - - NotAdmin: - ; You should still check for an empty string because the functions - ; UserInfo.dll looks for may not be present on Windows 95. (per kichik) - - #StrCmp $2 "" Win9x - #StrCpy $0 0 - ;MessageBox MB_OK 'User "$2" is in the "$3" group' - Pop $3 - Pop $2 - Pop $1 - Pop $0 - - Push 0 - Return - - ;Because we use IsNT, this is redundant. - #Win9x: - # ; comment/message below is by UserInfo.nsi author: - # ; This one means you don't need to care about admin or - # ; not admin because Windows 9x doesn't either - # ;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!" - # StrCpy $0 0 - - NotNT: - ;We are not NT - ;Win9x doesn't have "admin" users. - ;Let the user do whatever. - Pop $3 - Pop $2 - Pop $1 - Pop $0 - - Push 1 - -FunctionEnd - Function StrRep ;Written by dirtydingus 2003-02-20 04:30:09